我需要日期选择器对话框选项仅允许从当前日期开始使用,在统一文档中看不到设置选项的选项
void Start() {
if (PlayerPrefs.GetString("StartingDateTime") != null) {
if (PlayerPrefs.GetString("GoalDateTime") != null) {
startingDate = Convert.ToDateTime(PlayerPrefs.GetString("StartingDateTime"));
goalDate = Convert.ToDateTime(PlayerPrefs.GetString("GoalDateTime"));
startingDateLoadedText.text = startingDate.ToString();
goalDateLoadedText.text = goalDate.ToString();
totalWeeksInt = PlayerPrefs.GetInt("TotalWeeks");
SetWeeksToGoalDate();
SetCurrentWeek();
}
}
}
void Update() {
if (SelectedDate.newDate) {
if (newSelectedStartingDate) {
startingDate = SelectedDate.date;
startingDateText.text = SelectedDate.date.ToString("d/M/yyyy");
PlayerPrefs.SetString("StartingDateTime", SelectedDate.date.ToString());
newSelectedStartingDate = false;
} else if (newSelectedGoalDate) {
goalDate = SelectedDate.date;
goalDateText.text = SelectedDate.date.ToString("d/M/yyyy");
PlayerPrefs.SetString("GoalDateTime", SelectedDate.date.ToString());
newSelectedGoalDate = false;
}
SelectedDate.newDate = false;
}
}
void PickDate()
{
new AndroidJavaObject("android.app.DatePickerDialog", activity, new DateCallback(), SelectedDate.date.Year, SelectedDate.date.Month - 1, SelectedDate.date.Day).Call("show");
}
public void SelectStartingDate() {
activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
activity.Call("runOnUiThread", new AndroidJavaRunnable(PickDate));
newSelectedStartingDate = true;
}
public void SelectGoalDate()
{
activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
activity.Call("runOnUiThread", new AndroidJavaRunnable(PickDate));
newSelectedGoalDate = true;
}
public void SetWeeksToGoalDate() {
if (startingDate != null && goalDate != null) {
TimeSpan goalDateWeeks = goalDate - startingDate;
int weeks = goalDateWeeks.Days / 7;
PlayerPrefs.SetInt("TotalWeeks", weeks);
totalWeeksInt = weeks;
weightLossPeriodText.text = weeks.ToString();
}
}
我想了解一些有关通过Unity代码在何处设置选项的参考,或者是否需要通过Android插件设置插件并重新导入到应用中。