DatePickerSettings.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace Bitsplash.DatePicker
  8. {
  9. public partial class DatePickerSettings : MonoBehaviour
  10. {
  11. [SerializeField]
  12. private Font textFont;
  13. /// <summary>
  14. /// the text font used for UI.Text
  15. /// </summary>
  16. public Font TextFont
  17. {
  18. get { return textFont; }
  19. set
  20. {
  21. textFont = value;
  22. if (TextTypeChanged != null)
  23. TextTypeChanged();
  24. }
  25. }
  26. public event Action TextTypeChanged;
  27. DatePickerContent mContent = null;
  28. /// <summary>
  29. /// the datepicker content object for this date picker.
  30. /// </summary>
  31. public DatePickerContent Content
  32. {
  33. get
  34. {
  35. if (mContent == null)
  36. {
  37. var contents = GetComponentsInChildren<DatePickerContent>();
  38. if (contents.Length == 0)
  39. Debug.LogError("A DatePickerSettings behaviour must parent a DatePickerContent behaviour in a child GameObject");
  40. else
  41. if (contents.Length > 1)
  42. Debug.LogError("A DatePickerSettings behaviout may only have one child DatePickerContent behaviour ");
  43. else
  44. mContent = contents[0];
  45. }
  46. return mContent;
  47. }
  48. }
  49. private void Start()
  50. {
  51. }
  52. private void OnValidate()
  53. {
  54. foreach (var elem in GetComponentsInChildren<DatePickerElement>())
  55. {
  56. elem.OnValidate();
  57. }
  58. }
  59. }
  60. }