using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace JC.Unity.Picker { /// /// 日期选择组 /// public class DatePickerGroup : MonoBehaviour { public DateTime minDate, maxDate, selectDate; public List datePickerList; [SerializeField] Button btnClose; [SerializeField] Button btnEnter; public Action onEnter; void Awake() { minDate = new DateTime(1950, 1, 1, 0, 0, 0); maxDate = DateTime.Now; selectDate = new DateTime(2000, 1, 1, 0, 0, 0); Init(); } void Start() { if (btnClose) { btnClose.onClick.AddListener(() => { Destroy(transform.GetComponentInParent().gameObject); }); } if (btnEnter) { btnEnter.onClick.AddListener(() => { Destroy(transform.GetComponentInParent().gameObject); onEnter?.Invoke(this); }); } } public void Init() { for (int i = 0; i < datePickerList.Count; i++) { datePickerList[i].myGroup = this; datePickerList[i].Init(); } } public void onDateUpdate() { foreach (var item in datePickerList) { item.Refresh(); } // Debug.Log("当前选择日期:" + selectDate.ToString("yyyy年MM月dd日 HH : mm : ss")); } public string GetSelectDateStr() { return selectDate.ToString("yyyy-MM-dd"); } private float _height = -1; public float GetHeight() { if (_height == -1) { _height = transform.GetComponent().sizeDelta.y; } return _height; } } }