DatePicker, DateTimePicker, TimePicker¶
Nested Widgets Replacement¶
Nested widgets can be safely replaced with their analogs:
time can be displayed with Time24, Time12, TimeAnalog, TimeScroller
date can be displayed with Calendar, DateScroller
datetime can be displayed with DateTime, DateTimeScroller.
Options¶
Calendar
DateBase
Reference to the Date widget.
Date Change Only
bool
If true select date only when date changes; otherwise select date on click.
namespace UIWidgets.Examples
{
using System;
using UIWidgets;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Test DatePicker.
/// </summary>
public class TestDatePicker : MonoBehaviour
{
[SerializeField]
DatePicker PickerTemplate;
[SerializeField]
Text Result;
DateTime currentValue = DateTime.Today;
/// <summary>
/// Open picker and log selected value.
/// </summary>
public void Test()
{
// create picker by template
var picker = PickerTemplate.Clone();
// show picker
picker.Show(currentValue, ValueSelected, Canceled);
}
void ValueSelected(DateTime value)
{
currentValue = value;
Debug.Log("value: " + value);
}
void Canceled()
{
Debug.Log("canceled");
}
/// <summary>
/// Open picker and display selected value.
/// </summary>
public void TestShow()
{
// create picker by template
var picker = PickerTemplate.Clone();
// show picker
picker.Show(currentValue, ShowValueSelected, ShowCanceled);
}
void ShowValueSelected(DateTime value)
{
currentValue = value;
Result.text = "Value: " + value;
}
void ShowCanceled()
{
Result.text = "Canceled";
}
}
}