HomeView_BottomBarView.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using AppUI.Util.TabSwitcher;
  2. using JCUnityLib;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. public class HomeView_BottomBarView : MonoBehaviour
  9. {
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. Dictionary<string, Transform> actionMap = new Dictionary<string, Transform>
  14. {
  15. { "IconConnect", null },
  16. { "IconScreen", null },
  17. //{ "IconGuider", null },
  18. //{ "IconShop", null },
  19. //{ "IconNewUser", null },
  20. //{ "IconFriend", null },
  21. { "IconRank", null },
  22. { "IconSetUp", null }
  23. };
  24. SortChildObjects(actionMap);
  25. // 按条件禁用特定按钮的交互性
  26. if (CommonConfig.StandaloneMode) {
  27. DisableButtonInteractivity(actionMap, new List<string> { "IconGuider", "IconFriend", "IconRank" });
  28. }
  29. }
  30. void DisableButtonInteractivity(Dictionary<string, Transform> actionMap, List<string> buttonNames)
  31. {
  32. foreach (var buttonName in buttonNames)
  33. {
  34. // 检查 actionMap 中是否有该键且对应的 Transform 不为 null
  35. if (actionMap.TryGetValue(buttonName, out Transform buttonTransform) && buttonTransform != null)
  36. {
  37. Image image = buttonTransform.GetComponent<Image>();
  38. if (image != null) {
  39. image.color = new Color(200f / 255f, 200f / 255f, 200f / 255f, 130f / 255f);
  40. }
  41. Button button = buttonTransform.GetComponent<Button>();
  42. if (button != null)
  43. {
  44. button.interactable = false;
  45. button.gameObject.SetActive(false);
  46. }
  47. }
  48. }
  49. }
  50. void SortChildObjects(Dictionary<string, Transform> actionMap)
  51. {
  52. // 查找子对象并按名称填充 actionMap
  53. foreach (Transform child in transform)
  54. {
  55. if (actionMap.ContainsKey(child.name))
  56. {
  57. actionMap[child.name] = child;
  58. }
  59. else
  60. {
  61. // 如果子对象不在 actionMap 中,则隐藏它
  62. child.gameObject.SetActive(false);
  63. }
  64. }
  65. // 获取按字典定义顺序的子对象列表(过滤掉未找到的对象)
  66. var sortedChildren = actionMap.Values.Where(child => child != null).ToList();
  67. // 重新排列子对象
  68. for (int i = 0; i < sortedChildren.Count; i++)
  69. {
  70. sortedChildren[i].SetSiblingIndex(i);
  71. }
  72. }
  73. // Update is called once per frame
  74. //void Update()
  75. //{
  76. //}
  77. public void GoToConnect()
  78. {
  79. Debug.Log("进入连接页面");
  80. AudioMgr.ins.PlayBtn();
  81. //ViewMgr.Instance.ShowView<DeviceViewInfrared>();
  82. ViewManager2.ShowView<DeviceView>();
  83. }
  84. public void GoToSetup()
  85. {
  86. AudioMgr.ins.PlayBtn();
  87. GameObject settingsViewObj = ViewManager2.GetShowView<SettingsView>();
  88. //settingsViewObj.GetComponent<SmartBow.SettingsView>().ShowBoxSound(true);
  89. UITabSwitcher tab = settingsViewObj.GetComponent<UITabSwitcher>();
  90. tab.SetDefaultTab("BtnCommon");
  91. }
  92. public void GoToShop()
  93. {
  94. AudioMgr.ins.PlayBtn();
  95. if (ShopView.ins) return;
  96. ViewMgr.Instance.ShowView<ShopView>();
  97. }
  98. public void GoToGuider()
  99. {
  100. AudioMgr.ins.PlayBtn();
  101. //跳转至 设置-教程视频
  102. GameObject settingsViewObj = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_SettingsView);
  103. settingsViewObj.GetComponent<SmartBow.SettingsView>().OnClick_BtnNewUser();
  104. //NewUserGuiderManager.ins.ReviewNewUserGuide();
  105. }
  106. public void GoToNewUser()
  107. {
  108. AudioMgr.ins.PlayBtn();
  109. //ViewManager2.ShowView(ViewManager2.Path_ConnectGuidanceView);
  110. }
  111. public void GoToFriends()
  112. {
  113. Debug.Log("进入好友页面");
  114. AudioMgr.ins.PlayBtn();
  115. ViewManager2.ShowView(ViewManager2.Path_SocialView);
  116. }
  117. public void GoToRanking()
  118. {
  119. Debug.Log("进入排名页面");
  120. AudioMgr.ins.PlayBtn();
  121. ViewManager2.ShowView(ViewManager2.Path_RankingView);
  122. }
  123. }