using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using static Manager; public class ShiPingJianKongManager : UpdateManager { public static ShiPingJianKongManager Instance; // Start is called before the first frame update void Awake() { Instance = this; } int chooseroom = 0; public void chooseToggle(int index) { if(index!=0) { chooseroom = index; updateData(); } } public IEnumerator show() { while(ServerRoomVideoManager.csid==0) { yield return null; } chooseroom = ServerRoomVideoManager.csid; Debug.Log("chooseroom=2=>" + chooseroom); updateData(); } private void OnEnable() { StartCoroutine(show()); } public GameObject togglelist; ServerData sData; public static bool isinit; public override void updateData() { base.updateData(); Debug.Log("chooseroom=2=>" + chooseroom); if (chooseroom == 0) { return; } if (sData != null) { DataManager.Instance.GetVideo((data) => { List jiguilist = new List(); for (int i = 0; i < data.serverList.Count; i++) { togglelist.GetComponentsInChildren()[i].GetComponentInChildren().text = sData.serverList[i].name; togglelist.GetComponentsInChildren()[i].GetComponent().id = sData.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; } } updatejiankong(); }); } 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 = sData.serverList[i].name; togglelist.GetComponentsInChildren()[i].GetComponent().id = sData.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) { updatejiankong(); } // updateRoomData(); }); } } private void updatejiankong() { DataManager.Instance.GetVideo((data) => { for (int i = 0; i < allgame.Count; i++) { Destroy(allgame[i]); } allgame = new List(); int jlct = 0; int jfct = 0; for (int i = 0; i < data.serverList.Count; i++) { if (data.serverList[i].id == chooseroom) { for (int j = 0; j < data.serverList[i].videolist.Count; j++) { for (int z = 0; z < data.serverList[i].videolist[j].url.Count; z++) { if (data.serverList[i].videolist[j].type == 1) { //机笼 jlct++; GameObject jll = GameObject.Instantiate(jilongleft.gameObject, jilongleft.transform.parent); GameObject jlr = GameObject.Instantiate(jilongright.gameObject, jilongright.transform.parent); jll.SetActive(true); jlr.SetActive(true); jll.GetComponent().setdata(data.serverList[i].videolist[j].url[z], jlct); jlr.GetComponent().setdata(data.serverList[i].videolist[j].url[z], jlct); allgame.Add(jll); allgame.Add(jlr); } else { //机房 jfct++; GameObject jfl = GameObject.Instantiate(jifangleft.gameObject, jifangleft.transform.parent); GameObject jfr = GameObject.Instantiate(jifangright.gameObject, jifangright.transform.parent); jfl.SetActive(true); jfr.SetActive(true); jfl.GetComponent().setdata(data.serverList[i].videolist[j].url[z], jfct); jfr.GetComponent().setdata(data.serverList[i].videolist[j].url[z], jfct); allgame.Add(jfl); allgame.Add(jfr); } } } } } }); } public GameObject jilongleft; public GameObject jilongright; public GameObject jifangleft; public GameObject jifangright; List allgame = new List(); }