using ShadowStudio.Model; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XRTool.Util; using XRTool.WorldUI; namespace ShadowStudio.UI { [RequireComponent(typeof(WorldDlg))] public class PiZhuDlg : UnitySingleton { private Transform piZhuGroupTran; private ToggleGroup piZhuGroup; // Start is called before the first frame update void Start() { WorldDlg dlg = GetComponent(); piZhuGroupTran = dlg.GetBreadthChild("PiZhuGroup"); piZhuGroup = dlg.GetBreadthChild("PiZhuGroup"); Toggle[] toggles = piZhuGroupTran.GetComponentsInChildren(true); for (int i = 0; i < toggles.Length; i++) { Toggle toggle = toggles[i]; toggles[i].onValueChanged.AddListener((bool isOn) => { OnToggle(isOn, toggle); }); } } private void OnToggle(bool isOn, Toggle toggle) { if (isOn) { switch (toggle.name) { case "Up": NotePadComponent.CreateLocalNotePad(); //Debug.Log(toggle.name); break; case "Down": Debug.Log(toggle.name); break; case "Left": Debug.Log(toggle.name); break; case "Right": Debug.Log(toggle.name); break; case "RightUp": Debug.Log(toggle.name); break; } } if (!piZhuGroup.AnyTogglesOn()) { gameObject.SetActive(false); } } } }