| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using JCUnityLib;
- using System.Linq;
- using UnityEngine.UI;
- public class HomeView_BottomBarView : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- Dictionary<string, Transform> actionMap = new Dictionary<string, Transform>
- {
- { "IconConnect", null },
- { "IconGuider", null },
- //{ "IconShop", null },
- //{ "IconNewUser", null },
- { "IconFriend", null },
- { "IconRank", null },
- { "IconSetUp", null }
- };
- SortChildObjects(actionMap);
- // 按条件禁用特定按钮的交互性
- switch (CommonConfig.OP)
- {
- case OperatingPlatform.B:
- DisableButtonInteractivity(actionMap, new List<string> { "IconGuider", "IconFriend", "IconRank" });
- break;
- }
- }
- void DisableButtonInteractivity(Dictionary<string, Transform> actionMap, List<string> buttonNames)
- {
- foreach (var buttonName in buttonNames)
- {
- // 检查 actionMap 中是否有该键且对应的 Transform 不为 null
- if (actionMap.TryGetValue(buttonName, out Transform buttonTransform) && buttonTransform != null)
- {
- Image image = buttonTransform.GetComponent<Image>();
- if (image != null) {
- image.color = new Color(200f / 255f, 200f / 255f, 200f / 255f, 130f / 255f);
- }
- Button button = buttonTransform.GetComponent<Button>();
- if (button != null)
- {
- button.interactable = false;
- }
- }
- }
- }
- void SortChildObjects(Dictionary<string, Transform> actionMap)
- {
- // 查找子对象并按名称填充 actionMap
- foreach (Transform child in transform)
- {
- if (actionMap.ContainsKey(child.name))
- {
- actionMap[child.name] = child;
- }
- else
- {
- // 如果子对象不在 actionMap 中,则隐藏它
- child.gameObject.SetActive(false);
- }
- }
- // 获取按字典定义顺序的子对象列表(过滤掉未找到的对象)
- var sortedChildren = actionMap.Values.Where(child => child != null).ToList();
- // 重新排列子对象
- for (int i = 0; i < sortedChildren.Count; i++)
- {
- sortedChildren[i].SetSiblingIndex(i);
- }
- }
- // Update is called once per frame
- //void Update()
- //{
- //}
- public void GoToConnect()
- {
- Debug.Log("进入连接页面");
- AudioMgr.ins.PlayBtn();
- ViewMgr.Instance.ShowView<DeviceViewInfrared>();
- }
- public void GoToSetup()
- {
- AudioMgr.ins.PlayBtn();
- GameObject settingsViewObj = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_SettingsView);
- settingsViewObj.GetComponent<SmartBow.SettingsView>().ShowBoxSound(true);
- }
- public void GoToShop()
- {
- AudioMgr.ins.PlayBtn();
- if (ShopView.ins) return;
- ViewMgr.Instance.ShowView<ShopView>();
- }
- public void GoToGuider()
- {
- AudioMgr.ins.PlayBtn();
- //跳转至 设置-教程视频
- GameObject settingsViewObj = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_SettingsView);
- settingsViewObj.GetComponent<SmartBow.SettingsView>().OnClick_BtnNewUser();
- //NewUserGuiderManager.ins.ReviewNewUserGuide();
- }
- public void GoToNewUser()
- {
- AudioMgr.ins.PlayBtn();
- //ViewManager2.ShowView(ViewManager2.Path_ConnectGuidanceView);
- }
- public void GoToFriends()
- {
- Debug.Log("进入好友页面");
- AudioMgr.ins.PlayBtn();
- ViewManager2.ShowView(ViewManager2.Path_SocialView);
- }
- public void GoToRanking()
- {
- Debug.Log("进入排名页面");
- AudioMgr.ins.PlayBtn();
- ViewManager2.ShowView(ViewManager2.Path_RankingView);
- }
- }
|