NavTabButton.cs 834 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class NavTabButton : DGUI {
  5. public CallBackUtil.IntegerCallBack OnClick;
  6. public Text label;
  7. public Animator animator;
  8. private Button button;
  9. private bool m_Enabled;
  10. protected virtual void Awake ()
  11. {
  12. label = transform.FindChild ("Text").GetComponent<Text> ();
  13. animator = GetComponent<Animator> ();
  14. button = GetComponent<Button> ();
  15. button.onClick.AddListener (OnButtonClick);
  16. }
  17. void OnButtonClick()
  18. {
  19. OnClick (transform.GetSiblingIndex());
  20. }
  21. protected virtual void OnDestroy()
  22. {
  23. button.onClick.RemoveAllListeners ();
  24. }
  25. public bool enabled
  26. {
  27. set{
  28. m_Enabled = value;
  29. if (value)
  30. animator.Play ("TabBtnEnabled", 0, 0);
  31. else
  32. animator.Play ("TabBtnDisabled", 0, 0);
  33. }
  34. get{
  35. return m_Enabled;
  36. }
  37. }
  38. }