Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestButton.cs 1.5KB

12345678910111213141516171819202122232425262728293031
  1. using System.Collections.Generic;
  2. using UnityEngine.UI;
  3. class TestButton : Button
  4. {
  5. public bool isStateNormal { get { return currentSelectionState == SelectionState.Normal; } }
  6. public bool isStateHighlighted { get { return currentSelectionState == SelectionState.Highlighted; } }
  7. public bool isStatePressed { get { return currentSelectionState == SelectionState.Pressed; } }
  8. public bool isStateDisabled { get { return currentSelectionState == SelectionState.Disabled; } }
  9. public bool isStateSelected { get { return currentSelectionState == SelectionState.Selected; } }
  10. private bool IsTransitionTo(int index, SelectionState selectionState)
  11. {
  12. return index < m_StateTransitions.Count && m_StateTransitions[index] == selectionState;
  13. }
  14. public bool IsTransitionToNormal(int index) { return IsTransitionTo(index, SelectionState.Normal); }
  15. public bool IsTransitionToHighlighted(int index) { return IsTransitionTo(index, SelectionState.Highlighted); }
  16. public bool IsTransitionToPressed(int index) { return IsTransitionTo(index, SelectionState.Pressed); }
  17. public bool IsTransitionToDisabled(int index) { return IsTransitionTo(index, SelectionState.Disabled); }
  18. private readonly List<SelectionState> m_StateTransitions = new List<SelectionState>();
  19. public int StateTransitionCount { get { return m_StateTransitions.Count; } }
  20. protected override void DoStateTransition(SelectionState state, bool instant)
  21. {
  22. m_StateTransitions.Add(state);
  23. base.DoStateTransition(state, instant);
  24. }
  25. }