using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static Manager; public class ShuJuYuanGuanLi : MonoBehaviour { public Toggle xst; public Toggle yct; public Toggle yt; public Toggle zt; public Toggle dt; public Text dqsj; public Toggle bzt; public Toggle bst; public Toggle szt; public Toggle sst; public GameObject go; public List golist; int index = 0; private void Awake() { yt.onValueChanged.AddListener((b) => { if(b&& ainfo!=null) { index=0; refinfo(ainfo.yunneng_option); } }); zt.onValueChanged.AddListener((b) => { if (b && ainfo != null) { index=1; refinfo(ainfo.zongji_ption); } }); dt.onValueChanged.AddListener((b) => { if (b && ainfo != null) { index=2; refinfo(ainfo.donghuan_option); } }); } private void OnDestroy() { yt.onValueChanged.RemoveAllListeners(); zt.onValueChanged.RemoveAllListeners(); dt.onValueChanged.RemoveAllListeners(); } Toption nt; public void refinfo(Toption t) { nt=t; for (int i = 0; i < golist.Count; i++) { Destroy(golist[i]); } switch(t.current_data_source) { case 1: dqsj.text = "云能智维实时数据"; dqsj.color = Color.green; break; default: dqsj.text = "云能智维备份数据"; dqsj.color = new Color(277,115,24,255); break; } bzt.isOn = t.backup_data_switch_type == 1 ? true : false; bst.isOn = t.backup_data_switch_type != 1 ? true : false; szt.isOn = t.data_recover_type == 1 ? true : false; sst.isOn = t.data_recover_type != 1 ? true : false; for (int i = 0; i ().init(t.details[i]); golist.Add(ngo); } } AdminsystemInfo ainfo; private void OnEnable() { if(DataManager.Instance) { DataManager.Instance.getInfo((msg) => { ainfo = msg; xst.isOn = msg.general_option.update_time_display_switch; yct.isOn = !msg.general_option.update_time_display_switch; yt.isOn = true; refinfo(msg.yunneng_option); }); } } public void setty(bool b) { ainfo.general_option.update_time_display_switch= b; StartCoroutine( DataManager.Instance.SetgeneralSetting(b,(msg)=>{})); } public void setbackup(bool b) { nt.backup_data_switch_type = b?1:0; switch(index) { case 0: StartCoroutine(DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{})); break; case 1: StartCoroutine(DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{})); break; case 2: StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{})); break; } } public void setrecover(bool b) { nt.data_recover_type = b?1:0; switch(index) { case 0: StartCoroutine( DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{})); break; case 1: StartCoroutine( DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{})); break; case 2: StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{})); break; } } }