1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using SC.XR.Unity;
- public class SettingPanel : MonoBehaviour
- {
- 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);
- }
- 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()
- {
- DataManager.Instance.SaveSpoits();
- DataManager.Instance.IsSavedData = true;
- }
- }
|