DatePicker, DateTimePicker, TimePicker

Nested Widgets Replacement

Nested widgets can be safely replaced with their analogs:

Note

See Windows Animations for open and closed animations.

DatePicker Options

  • CloseButton Button

    Button to close picker without selected value.

  • HideOnModalClick bool

    Close picker on background click outside of picker.

  • Mode PickerMode

    Picker mode:

    • Close On Select

      Close picker right after value selected.

    • Close On OK

      Close picker on OK click.

  • Date Change Only bool

    If true select date only when date changes; otherwise select date on click.

  • OkButton Button

    OK button with selected value.

  • Calendar DateBase

    Reference to the Date widget.

DateTimePicker Options

  • CloseButton Button

    Button to close picker without selected value.

  • HideOnModalClick bool

    Close picker on background click outside of picker.

  • DateTimeWidget DateTimeWidget

    Reference to the DateTime widget.

TimePicker Options

  • CloseButton Button

    Button to close picker without selected value.

  • HideOnModalClick bool

    Close picker on background click outside of picker.

  • Time TimeBase

    Reference 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");
                }
        }
}