123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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));
-
- GameManager.Instance.StartCoroutine(UIEditorPanel.Instance.SetSpoitInfo());
- DataManager.Instance.IsSavedData = true;
- }
- }
|