123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using SC.XR.Unity;
- using Blue;
- using LitJson;
- using Immersal.AR;
- using XRTool.Util;
- public class SettingPanel : AbstractController
- {
- public Text spMRtext;
- public Toggle MinMap;
- public Toggle NoMinMap;
- public Toggle DingWei;
- public Toggle feiDingWei;
- public Toggle LuJIng;
- public Toggle NoLuJIng;
- 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;
- SpoitValue nowsp;
- public static Dictionary<int, bool> dingweilist = new Dictionary<int, bool>();
- private void Awake()
- {
- Lines = new List<Toggle>();
- SaveData.onClick.AddListener(OnClickSaveData);
- MinMap.onValueChanged.AddListener(OnMinMapValueChange);
- LuJIng.onValueChanged.AddListener(OnLuJIngValueChange);
- DingWei.onValueChanged.AddListener(DingWeiValueChange);
- setMsg(null);
- }
- private void DingWeiValueChange(bool arg0)
- {
- if(nowsp!=null)
- {
- if (dingweilist.ContainsKey(nowsp.id))
- {
- dingweilist[nowsp.id] = arg0;
- }
- else
- {
- dingweilist.Add(nowsp.id,arg0);
- }
- JsonData data = new JsonData();
- data["id"] = nowsp.id;
- data["projectId"] = SceneChoose.Sid;
- data["location"] = arg0;
- HttpTool.Instance.Post("/viewpoint/locationPoint", data.ToJson(), (string str) => { });
- setdingwei(arg0);
- }
- }
- private void OnEnable()
- {
- MinMap.interactable = false;
- NoMinMap.interactable = false;
- HttpTool.Instance.Get("/user/getUserInfo", (string str) =>
- {
- MinMap.interactable = true;
- NoMinMap.interactable = true;
- JsonData data = JsonMapper.ToObject(str);
- if (data["data"]["minMap"].ToString() == "0")
- {
- NoMinMap.isOn = true;
- m_MinMap.gameObject.SetActive(false);
- }
- else
- {
- MinMap.isOn = true;
- m_MinMap.gameObject.SetActive(true);
- }
- });
- // HttpTool.Instance.Post("/viewpoint/locationPoint", data.ToJson(), (string str) => { });
- // MinMap.isOn = this.GetService<IMinMapService>().setMinMap == 1 ? true : false;
- }
- public void setMsg(SpoitValue sv)
- {
- nowsp = sv;
- if (sv!=null)
- {
- feiDingWei.gameObject.SetActive(true);
- DingWei.gameObject.SetActive(true);
- spMRtext.text = sv.name;
- if (dingweilist.ContainsKey(nowsp.id))
- {
- if(dingweilist[nowsp.id])
- {
- setdingwei(true);
- DingWei.isOn = true;
- }
- else
- {
- if (ARSpace.isFind)
- {
- setdingwei(false);
- }
- feiDingWei.isOn = true;
- }
- }
- else
- {
- if(sv.location)
- {
- dingweilist.Add(nowsp.id,true);
- setdingwei(true);
- DingWei.isOn = true;
- }
- else
- {
- if (ARSpace.isFind)
- {
- setdingwei(false);
- }
- feiDingWei.isOn = true;
- }
- }
- }
- else
- {
- spMRtext.text = "----";
- feiDingWei.isOn = false;
- feiDingWei.gameObject.SetActive(false);
- DingWei.gameObject.SetActive(false);
- //if(ARSpace.isFind)
- //{
- setdingwei(true);
- //}
- }
- }
- public void setdingwei(bool isopen)
- {
- if(isopen&&!MoveChange.islixian)
- XRLocalizer.Instance.gameObject.SetActive(true);
- else
- {
- XRLocalizer.Instance.gameObject.SetActive(false);
- }
- }
- public void Init()
- {
- CreateLines();
- // MinMap.isOn = true;
- // m_MinMap.gameObject.SetActive(true);
- gameObject.SetActive(false);
- }
- private void OnMinMapValueChange(bool ison)
- {
- Debug.Log("OnMinMapValueChange===>"+ison);
- JsonData data = new JsonData();
- data["minMap"] = ison?1:0;
- HttpTool.Instance.Post("/user/settings", data.ToJson(), (string str)=> { });
- TimerMgr.Instance.CreateTimer(()=> { m_MinMap.gameObject.SetActive(ison); },0.3f,3);
-
- }
- private void OnLuJIngValueChange(bool ison)
- {
- m_RouteCtr.gameObject.SetActive(ison);
- for (int i = 0; i < m_MinMap.list_route.Count; i++)
- {
- m_MinMap.list_route[i].gameObject.SetActive(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();
- GameManager.Instance.StartCoroutine(UIEditorPanel.Instance.SetSpoitInfo());
- DataManager.Instance.IsSavedData = true;
- }
- }
|