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.
Note
See Windows Animations for open and closed animations.
DatePicker Options
CloseButton
ButtonButton to close picker without selected value.
HideOnModalClick
boolClose picker on background click outside of picker.
Mode
PickerModePicker mode:
Close On Select
Close picker right after value selected.
Close On OK
Close picker on OK click.
Date Change Only
boolIf true select date only when date changes; otherwise select date on click.
OkButton
ButtonOK button with selected value.
Calendar
DateBaseReference to the Date widget.
DateTimePicker Options
CloseButton
ButtonButton to close picker without selected value.
HideOnModalClick
boolClose picker on background click outside of picker.
DateTimeWidget
DateTimeWidgetReference to the DateTime widget.
TimePicker Options
CloseButton
ButtonButton to close picker without selected value.
HideOnModalClick
boolClose picker on background click outside of picker.
Time
TimeBaseReference to the Time widget.
Minimal Code
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 async void TestAsync()
{
// create picker by template
var picker = PickerTemplate.Clone();
// show picker
var value = await picker.ShowAsync(currentValue);
if (value.Success)
{
currentValue = value;
Debug.Log("value: " + value);
}
else
{
Debug.Log("canceled");
}
}
/// <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");
}
}
}