using System; using UnityEngine.Events; using UnityEngine.UI; namespace AibisDream { public class BaseButton : Button { public SelectionType CurSelectionState => TransStateToType(currentSelectionState); public UnityEvent onStateTransition = new(); protected override void DoStateTransition(SelectionState state, bool instant) { if (!gameObject.activeInHierarchy) return; base.DoStateTransition(state, instant); onStateTransition?.Invoke(TransStateToType(state), instant); } protected static SelectionType TransStateToType(SelectionState state) { return Enum.Parse(state.ToString()); } } /// /// 因为作用域问题把枚举转出来用 /// public enum SelectionType { /// /// The UI object can be selected. /// Normal, /// /// The UI object is highlighted. /// Highlighted, /// /// The UI object is pressed. /// Pressed, /// /// The UI object is selected /// Selected, /// /// The UI object cannot be selected. /// Disabled } }