using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; using SC.XR.Unity; using Blue; public class SettingPanel : AbstractController { public Toggle MinMap; public Toggle LuJIng; public Transform ChooseLine; public Toggle LineItem; public Transform LineItemParent; public Button SaveData; [SerializeField, Tooltip("小地图信息")] private MinMap m_MinMap; [SerializeField, Tooltip("路径控制器")] private RouteCtr m_RouteCtr; private List Lines; private void Awake() { Lines = new List(); SaveData.onClick.AddListener(OnClickSaveData); MinMap.onValueChanged.AddListener(OnMinMapValueChange); LuJIng.onValueChanged.AddListener(OnLuJIngValueChange); } private void OnEnable() { MinMap.isOn = this.GetService().setMinMap == 1 ? true : false; } public void Init() { CreateLines(); MinMap.isOn = true; //m_MinMap.gameObject.SetActive(true); LuJIng.isOn = true; if (Lines.Count > 0) { Lines[0].isOn = true; } gameObject.SetActive(false); } private void OnMinMapValueChange(bool ison) { m_MinMap.gameObject.SetActive(ison); } private void OnLuJIngValueChange(bool ison) { m_RouteCtr.gameObject.SetActive(ison); for (int i = 0; i < Lines.Count; i++) { Lines[i].interactable = ison; } } private void CreateLines() { var lines = m_RouteCtr.List_route; for (int i = 0; i < lines.Count; i++) { Toggle obj = Instantiate(LineItem, LineItemParent); obj.isOn = false; obj.transform.Find("Label").GetComponent().text = lines[i].name; var item = obj.gameObject.AddComponent(); item.OnToggleSelect += OnCLickToggle; obj.gameObject.SetActive(true); Lines.Add(obj); } } private void OnCLickToggle(int index, bool ison) { m_RouteCtr.SettingLuJing(index, ison); m_MinMap.SetRoute(index, ison); } private void OnClickSaveData() { this.SendCommand(new MinMapGetSetCommand(m_MinMap.gameObject.activeSelf ? 1 : 0)); DataManager.Instance.SaveSpoits(); DataManager.Instance.IsSavedData = true; } }