12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Bitsplash.DatePicker
- {
- public class MonthTextBox : DatePickerText , IDatePickerSettingsItem
- {
- [SerializeField]
- private string dateFormat = "MMMM, yyyy";
- public string DateFormat
- {
- get { return dateFormat; }
- set
- {
- dateFormat = value;
- RefreshText();
- }
- }
- public int Order { get { return 8; } }
- public string EditorTitle
- {
- get { return "Month Text Box - " + gameObject.name; }
- }
- protected override void SetContent(DatePickerContent content)
- {
- if (Content != null)
- Content.OnDisplayChanged.RemoveListener(DisplayChanged);
- base.SetContent(content);
- if (Content != null)
- {
- Content.OnDisplayChanged.AddListener(DisplayChanged);
- DisplayChanged();
- }
- }
- void RefreshText()
- {
- if (Content == null)
- return;
- try
- {
- Text = (Content.DisplayDate.ToString(dateFormat));
- }
- catch (Exception)
- {
- Debug.LogWarning("Invalid date format for text box - " + DateFormat);
- }
- }
- void DisplayChanged()
- {
- RefreshText();
- }
- void OnDestroy()
- {
- if (Content != null)
- Content.OnDisplayChanged.RemoveListener(DisplayChanged);
- }
- }
- }
|