SettingsView.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. using SmartBow;
  6. using TMPro;
  7. using AppUI.Manager.View;
  8. namespace AppUI.View.Home.SettingsView
  9. {
  10. public class SettingsView : MonoBehaviour, MenuBackInterface
  11. {
  12. //[SerializeField] Transform panelLeftContent;
  13. // Start is called before the first frame update
  14. void Start()
  15. {
  16. PersistenHandler.ins?.menuBackCtr.views.Add(this);
  17. }
  18. void OnDestroy()
  19. {
  20. PersistenHandler.ins?.menuBackCtr.views.Remove(this);
  21. }
  22. public void OnClick_Back()
  23. {
  24. AudioMgr.ins.PlayBtn();
  25. ViewManager.HideView(UIViewType.SettingsView);
  26. }
  27. //void SortChildObjects(Dictionary<string, Transform> actionMap)
  28. //{
  29. // // 查找子对象并按名称填充 actionMap
  30. // foreach (Transform child in panelLeftContent)
  31. // {
  32. // if (actionMap.ContainsKey(child.name))
  33. // {
  34. // actionMap[child.name] = child;
  35. // }
  36. // else
  37. // {
  38. // // 如果子对象不在 actionMap 中,则隐藏它
  39. // child.gameObject.SetActive(false);
  40. // }
  41. // }
  42. // // 获取按字典定义顺序的子对象列表(过滤掉未找到的对象)
  43. // var sortedChildren = actionMap.Values.Where(child => child != null).ToList();
  44. // // 重新排列子对象
  45. // for (int i = 0; i < sortedChildren.Count; i++)
  46. // {
  47. // sortedChildren[i].SetSiblingIndex(i);
  48. // }
  49. //}
  50. // Update is called once per frame
  51. void Update()
  52. {
  53. }
  54. //public void OnClick_PanelLeftItem(Transform target)
  55. //{
  56. // foreach (Transform item in panelLeftContent)
  57. // {
  58. // if (item.name == "BtnSignOut") continue;
  59. // TMP_Text text = item.Find("Text").GetComponent<TMP_Text>();
  60. // if (item == target)
  61. // {
  62. // Color oldColor = text.color;
  63. // if (oldColor != Color.white)
  64. // {
  65. // text.color = Color.white;
  66. // AudioMgr.ins.PlayBtn();
  67. // ShowBox(item.name);
  68. // }
  69. // }
  70. // else
  71. // {
  72. // text.color = new Color32(153, 153, 153, 255);
  73. // }
  74. // }
  75. //}
  76. //void ShowBox(string itemName)
  77. //{
  78. // // 定义所有 ShowBox 方法,并将初始状态设为 false
  79. // var actionMap = new Dictionary<string, System.Action<bool>>
  80. // {
  81. // { "BtnCommon", ShowBoxCommon },
  82. // { "BtnBows", ShowBoxBows }
  83. // };
  84. // // 先将所有状态设为 false
  85. // foreach (var action in actionMap.Values)
  86. // {
  87. // action(false);
  88. // }
  89. // // 将指定的 itemName 对应的按钮设为 true
  90. // if (actionMap.TryGetValue(itemName, out var selectedAction))
  91. // {
  92. // selectedAction(true);
  93. // }
  94. //}
  95. //public void ShowBoxCommon(bool show)
  96. //{
  97. // transform.Find("PanelContent/BoxCommon").gameObject.SetActive(show);
  98. //}
  99. //void ShowBoxBows(bool show)
  100. //{
  101. // transform.Find("PanelContent/BoxBows").gameObject.SetActive(show);
  102. //}
  103. public bool OnMenuBack()
  104. {
  105. //ViewManager2.HideView<SettingsView>();
  106. ViewManager.HideView(UIViewType.SettingsView);
  107. return true;
  108. }
  109. }
  110. }