HomeView_TopBarView.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. [Serializable]
  7. public class TopBarButtonInfo
  8. {
  9. public string Name;
  10. public Image Icon;
  11. public Text text;
  12. public bool selected;
  13. }
  14. public class HomeView_TopBarView : MonoBehaviour
  15. {
  16. public List<TopBarButtonInfo> topBarButtonInfos;
  17. // Start is called before the first frame update
  18. void Start()
  19. {
  20. TopBarButtonInfo topBarButtonInfo = topBarButtonInfos[0];
  21. topBarButtonInfo.Icon.color = new Color32(0, 0, 0, 255);
  22. topBarButtonInfo.text.color = new Color32(48, 57, 57, 255);
  23. }
  24. // Update is called once per frame
  25. //void Update()
  26. //{
  27. //}
  28. public void onChangeType(int index)
  29. {
  30. if (index > 0 || index < topBarButtonInfos.Count) {
  31. for (int i = 0; i < topBarButtonInfos.Count; i++)
  32. {
  33. TopBarButtonInfo topBarButtonInfo = topBarButtonInfos[i];
  34. if (i == index) {
  35. topBarButtonInfo.Icon.color = new Color32(0, 0, 0, 255);
  36. topBarButtonInfo.text.color = new Color32(48, 57, 57, 255);
  37. }
  38. else {
  39. topBarButtonInfo.Icon.color = new Color32(255, 255, 255, 255);
  40. topBarButtonInfo.text.color = new Color32(141, 150, 151, 255);
  41. }
  42. }
  43. }
  44. }
  45. }