12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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<Toggle> Lines;
- private void Awake()
- {
- Lines = new List<Toggle>();
- SaveData.onClick.AddListener(OnClickSaveData);
- MinMap.onValueChanged.AddListener(OnMinMapValueChange);
- LuJIng.onValueChanged.AddListener(OnLuJIngValueChange);
- }
- private void OnEnable()
- {
- MinMap.isOn = this.GetService<IMinMapService>().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>().text = lines[i].name;
- var item = obj.gameObject.AddComponent<LuJingItem>();
- 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;
- }
- }
|