using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XCharts.Runtime; using static Manager; public class DianLiJianKongManager : UpdateManager { public List lcs; public static DianLiJianKongManager Instance; public GameObject togglelist; public Text jiguiname; public wsdItem item; List items = new List(); private void Awake() { Instance = this; } ServerData sData; public static bool isinit; public override void updateData() { base.updateData(); if(chooseroom==0) { chooseroom = ServerRoomManager.chooswsd; } if (chooseroom == 0) { return; } Debug.Log("chooseroom=2=>" + chooseroom); if (sData!=null) { DataManager.Instance.GetTwoWsd(chooseroom, (data) => { Debug.Log("GetTwoWsd=2=>" + data); Toggle[] ts = togglelist.GetComponentsInChildren(); for (int i = 0; i < ts.Length; i++) { if (ts[i].GetComponent().id == chooseroom) { ts[i].isOn = true; break; } } sjds = data; updateRoomData(); }); } else { DataManager.Instance.GetWSD((data) => { sData = data; List jiguilist = new List(); for (int i = 0; i < data.serverList.Count; i++) { togglelist.GetComponentsInChildren()[i].GetComponentInChildren().text = data.serverList[i].name; togglelist.GetComponentsInChildren()[i].GetComponent().id = data.serverList[i].id; } Toggle[] ts = togglelist.GetComponentsInChildren(); for (int i = 0; i < ts.Length; i++) { if (ts[i].GetComponent().id == chooseroom) { ts[i].isOn = true; break; } } if (chooseroom!=0) { DataManager.Instance.GetTwoWsd(chooseroom, (data) => { Debug.Log("GetTwoWsd=2=>" + data); sjds = data; updateRoomData(); }); } // updateRoomData(); }); } } List sjds =new List(); void updateRoomData() { for (int i = 0; i < items.Count; i++) { Destroy(items[i]); } for (int i = 0; i < sjds.Count; i++) { GameObject go = GameObject.Instantiate(item.gameObject, item.transform.parent); go.GetComponent().initData(sjds[i]); go.SetActive(true); items.Add(go); } updatetu(); } int chooseroom ; public void chooseToggle(int index) { chooseroom = index; updateData(); } int jiguiindex = 0; public void chooseJiGuiToggle(int i) { jiguiindex = i; updatetu(); } public void updatetu() { if(jiguiindex==0) { jiguiindex = sjds[0].id; jiguiname.text = sjds[0].name; } for (int i = 0; i < sjds.Count; i++) { if(sjds[i].id == jiguiindex) { jiguiname.text = sjds[i].name; break; } } DataManager.Instance.GetTwoWsdTb(chooseroom, jiguiindex, (data) => { for (int i = 0; i < data.Count; i++) { setLineData(lcs[i], data[i]); } }); } private void OnDisable() { sData = null; } public IEnumerator show() { while (ServerRoomVideoManager.csid == 0) { yield return null; } chooseroom = ServerRoomManager.chooswsd; Debug.Log("chooseroom=1=>" + chooseroom); updateData(); } private void OnEnable() { StartCoroutine(show()); } }