Test.cs 873 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public enum ETab
  5. {
  6. A, B
  7. }
  8. public class Test : MonoBehaviour
  9. {
  10. private TabButtonGroup m_TabGroup;
  11. void Start()
  12. {
  13. m_TabGroup = new TabButtonGroup();
  14. Transform A = transform.Find("A");
  15. NormalTabButton AButton = new NormalTabButton(this.m_TabGroup);
  16. AButton.GameObject = A.gameObject;
  17. Transform B = transform.Find("B");
  18. NormalTabButton BButton = new NormalTabButton(this.m_TabGroup);
  19. BButton.GameObject = B.gameObject;
  20. m_TabGroup.Select(0);
  21. m_TabGroup.OnSelect += OnTabSelect;
  22. }
  23. private void OnTabSelect(int tab)
  24. {
  25. if (tab == (int)ETab.A)
  26. {
  27. Debug.Log("AA");
  28. }
  29. else if (tab == (int)ETab.B)
  30. {
  31. Debug.Log("BB");
  32. }
  33. }
  34. }