DatePickerΒΆ

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