123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 |
- using Newtonsoft.Json.Linq;
- using Newtonsoft.Json;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- using UnityEngine.Serialization;
- using UnityEngine.UI;
- using System.Threading.Tasks;
- using UnityAsync;
- using WaitUntil = UnityAsync.WaitUntil;
- using System.Reflection;
- using XCharts.Runtime;
- [System.Serializable]
- public class FloodGate
- {
- public int GateNumber;
- public bool IsOpen;
- public float CurrentFlow;
- public float CurrentOpening;
- public int Status; // 1 for operational, 0 for faulty
- public string updateTime;
- }
- [System.Serializable]
- public class FloodGateLocationData
- {
- public float CurrentWaterLevel;
- public FloodGate[] FloodGates;
- }
- [System.Serializable]
- public class FloodGateStatusData
- {
- public FloodGateLocationData BuYuan;
- public FloodGateLocationData TaoKou;
- public bool success = false;
- public int BuYuanTotalGates => BuYuan.FloodGates.Length;
- public int BuYuanOperationalGates => CountOperationalGates(BuYuan.FloodGates);
- public int TaoKouTotalGates => TaoKou.FloodGates.Length;
- public int TaoKouOperationalGates => CountOperationalGates(TaoKou.FloodGates);
- private int CountOperationalGates(FloodGate[] gates)
- {
- int count = 0;
- foreach (var gate in gates)
- {
- if (gate.Status == 1) count++;
- }
- return count;
- }
- }
- [System.Serializable]
- public class LocationWeatherData
- {
- public float currentWaterLevel;
- public float rainfall;
- public float floodDischarge;
- public float temperature;
- public string weather;
- }
- [System.Serializable]
- public class StationInspection
- {
- public InspectionDaily daily;
- public InspectionDaily monthly;
- public InspectionDaily yearly;
- }
- [System.Serializable]
- public class InspectionDaily
- {
- public int operationStaffCount;
- public int inspectionTasksCount;
- public int inspectionKilometers;
- public int faultHazardCount;
- public int processedFaultCount;
- public int engineeringMaintenanceCount;
- }
- [System.Serializable]
- public class AlertData
- {
- public bool success = false;
- public Alerts alerts;
- }
- [System.Serializable]
- public class Alerts
- {
- public List<AlertDataEvent> warningEvents = new List<AlertDataEvent>();
- public List<AlertDataEvent> floodForecasts = new List<AlertDataEvent>();
- public List<AlertDataEvent> weatherForecasts = new List<AlertDataEvent>();
- public List<AlertDataEvent> threeLineWarnings = new List<AlertDataEvent>();
- }
- [System.Serializable]
- public class AlertDataEvent
- {
- public int id;
- public string title;
- public string location;
- public string time;
- }
- public class BigScreenLayer : MonoBehaviour
- {
- public VerticalLayoutGroup content;
- public RectTransform znz;
- public Button gkButton;
- public Button normalButton;
- public Button clearBtn;
- public Button exitBtn;
- public Button exitJJBtn;
- public Button ddysButton;
- public Button exit_ddysButton;
- public GameObject gk;
- public GameObject normal;
- public YZTLayer zTLayer;
- public RectTransform miniMap;
- public RectTransform rightContent;
- public RingChart floodRingChart;
- public Button floodButton;
- public Text[] floodTexts;
- public RectTransform popWindow;
- public GameObject floodDataPrefab;
- public Button[] floodListBtns;
- public GridLayoutGroup[] floodLists;
- public Button floodListExitBtn;
- public Text swValue1;
- public Text swValue2;
- public Text swValue3;
- public Text swValue4;
- public Text swValue5;
- public Dropdown swDrop0;
- public Text yunValue1;
- public Text yunValue2;
- public Text yunValue3;
- public Text yunValue4;
- public Text yunValue5;
- public Text yunValue6;
- public int currentYunIndex = 0;
- public Dropdown yunDrop0;
- public Dropdown yunDrop1;
- List<LayerBtn> layerBtns = new List<LayerBtn>();
- // Start is called before the first frame update
- public GameObject obsItemPrefab;
- private List<ObsItem> obsItemList = new List<ObsItem>();
- private Transform obsItemContent;
- public ObsPlayerPanel obsPlayerPanel;
- private InputField _obsSearchInputField;
- public GameObject WaterRangeCtrlPanel;
- public GameObject yjPrefab;
- public Button[] yjBtns;
- public GridLayoutGroup[] yjLayout;
- public Sprite[] sprites;
- async void Start()
- {
- CameraManager.SwitchCamera(0);
- StaticLod.instance.OnFoucusStatic(0);
- InitButton();
- obsPlayerPanel = this.transform.Find("ObsPlayerPanel").GetComponent<ObsPlayerPanel>();
- obsPlayerPanel.gameObject.SetActive(false);
- obsItemContent = this.transform.Find("BigSc/ShiPinJuZhen/ScrollView/Viewport/Content");
- _obsSearchInputField = this.transform.Find("BigSc/ShiPinJuZhen/InputField").GetComponent<InputField>();
- _obsSearchInputField.onValueChanged.AddListener(SearchObsItem);
- InitFloodGateData();
- InitHydrologicalData();
- InitLayerBtns();
- InitObsItems();
- InitInspectionStatistics();
- InitAlert();
- }
- void InitButton()
- {
- normalButton.onClick.AddListener(() =>
- {
- normal.gameObject.SetActive(true);
- gk.gameObject.SetActive(false);
- });
- gkButton.onClick.AddListener(() =>
- {
- gk.gameObject.SetActive(true);
- miniMap.gameObject.SetActive(true);
- rightContent.parent.gameObject.SetActive(false);
- normal.gameObject.SetActive(false);
- });
- clearBtn.onClick.AddListener(() =>
- {
- normal.gameObject.SetActive(false);
- gk.gameObject.SetActive(false);
- exitBtn.gameObject.SetActive(true);
- normalButton.gameObject.SetActive(false);
- gkButton.gameObject.SetActive(false);
- clearBtn.gameObject.SetActive(false);
- ddysButton.gameObject.SetActive(false);
- });
- exitBtn.onClick.AddListener(() =>
- {
- normal.gameObject.SetActive(true);
- gk.gameObject.SetActive(false);
- exitBtn.gameObject.SetActive(false);
- normalButton.gameObject.SetActive(true);
- gkButton.gameObject.SetActive(true);
- clearBtn.gameObject.SetActive(true);
- ddysButton.gameObject.SetActive(true);
- });
- exitJJBtn.onClick.AddListener(() =>
- {
- normal.gameObject.SetActive(true);
- gk.gameObject.SetActive(false);
- });
- ddysButton.onClick.AddListener(() =>
- {
- StaticLod.instance.OnFoucusStatic(-1);
- normal.gameObject.SetActive(false);
- gk.gameObject.SetActive(false);
- normalButton.gameObject.SetActive(false);
- gkButton.gameObject.SetActive(false);
- clearBtn.gameObject.SetActive(false);
- WaterRangeCtrlPanel.SetActive(true);
- });
- exit_ddysButton.onClick.AddListener(() =>
- {
- StaticLod.instance.OnFoucusStatic(0);
- WaterRangeCtrlPanel.SetActive(false);
- normal.gameObject.SetActive(true);
- gk.gameObject.SetActive(false);
- exitBtn.gameObject.SetActive(false);
- normalButton.gameObject.SetActive(true);
- gkButton.gameObject.SetActive(true);
- clearBtn.gameObject.SetActive(true);
- ddysButton.gameObject.SetActive(true);
- });
- // public Button ddysButton;
- // public Button exit_ddysButton;
- }
- private async Task InitAlert()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.alertData.success;
- });
- for (int i = 0; i < yjLayout.Length; i++)
- {
- yjLayout[i].transform.parent.parent.parent.gameObject.SetActive(false);
- }
- yjLayout[0].transform.parent.parent.parent.gameObject.SetActive(true);
- for (int i = 0; i < GlobalData.alertData.alerts.warningEvents.Count; i++)
- {
- GameObject obj = Instantiate(yjPrefab);
- obj.transform.SetParent(yjLayout[0].transform);
- obj.transform.localScale = Vector3.one;
- obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].id.ToString();
- obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].title.ToString();
- obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].location.ToString();
- obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].time.ToString();
- }
- for (int i = 0; i < GlobalData.alertData.alerts.floodForecasts.Count; i++)
- {
- GameObject obj = Instantiate(yjPrefab);
- obj.transform.SetParent(yjLayout[1].transform);
- obj.transform.localScale = Vector3.one;
- obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].id.ToString();
- obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].title.ToString();
- obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].location.ToString();
- obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].time.ToString();
- }
- for (int i = 0; i < GlobalData.alertData.alerts.weatherForecasts.Count; i++)
- {
- GameObject obj = Instantiate(yjPrefab);
- obj.transform.SetParent(yjLayout[2].transform);
- obj.transform.localScale = Vector3.one;
- obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].id.ToString();
- obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].title.ToString();
- obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].location.ToString();
- obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].time.ToString();
- }
- for (int i = 0; i < GlobalData.alertData.alerts.threeLineWarnings.Count; i++)
- {
- GameObject obj = Instantiate(yjPrefab);
- obj.transform.SetParent(yjLayout[3].transform);
- obj.transform.localScale = Vector3.one;
- obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].id.ToString();
- obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].title.ToString();
- obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].location.ToString();
- obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].time.ToString();
- }
- for (int i = 0; i < yjBtns.Length; i++)
- {
- int temp = i;
- yjBtns[i].onClick.AddListener(() =>
- {
- for (int j = 0; j < yjBtns.Length; j++)
- {
- yjBtns[j].transform.GetChild(0).GetComponent<Text>().color = Color.gray;
- }
- yjBtns[temp].transform.GetChild(0).GetComponent<Text>().color = Color.white;
- for (int j = 0; j < yjLayout.Length; j++)
- {
- yjLayout[j].transform.parent.parent.parent.gameObject.SetActive(false);
- }
- yjLayout[temp].transform.parent.parent.parent.gameObject.SetActive(true);
- });
- }
- }
- private async Task InitHydrologicalData()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.locationWeatherData.Count > 0;
- });
- ChangeLocationWeatherData(0);
- swDrop0.onValueChanged.AddListener((index) =>
- {
- ChangeLocationWeatherData(index);
- });
- }
- private void ChangeLocationWeatherData(int index)
- {
- swValue1.text = GlobalData.locationWeatherData[index].currentWaterLevel.ToString();
- swValue2.text = GlobalData.locationWeatherData[index].rainfall.ToString();
- swValue3.text = GlobalData.locationWeatherData[index].temperature.ToString();
- swValue4.text = GlobalData.locationWeatherData[index].weather.ToString();
- swValue5.text = GlobalData.locationWeatherData[index].floodDischarge.ToString();
- }
- private async Task InitFloodGateData()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.floorGateData.success;
- });
- floodTexts[0].text = (GlobalData.floorGateData.BuYuanOperationalGates + GlobalData.floorGateData.TaoKouOperationalGates).ToString();
- floodTexts[1].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates - GlobalData.floorGateData.BuYuanOperationalGates - GlobalData.floorGateData.TaoKouOperationalGates).ToString();
- floodTexts[2].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates).ToString();
- floodButton.onClick.AddListener(() =>
- {
- popWindow.gameObject.SetActive(true);
- });
- floodListExitBtn.onClick.AddListener(() =>
- {
- popWindow.gameObject.SetActive(false);
- });
- floodListBtns[0].onClick.AddListener(() =>
- {
- floodListBtns[0].GetComponent<Image>().sprite = sprites[0];
- floodListBtns[1].GetComponent<Image>().sprite = sprites[1];
- floodLists[0].transform.parent.parent.parent.gameObject.SetActive(true);
- floodLists[1].transform.parent.parent.parent.gameObject.SetActive(false);
- });
- floodListBtns[1].onClick.AddListener(() =>
- {
- floodListBtns[0].GetComponent<Image>().sprite = sprites[1];
- floodListBtns[1].GetComponent<Image>().sprite = sprites[0];
- floodLists[0].transform.parent.parent.parent.gameObject.SetActive(false);
- floodLists[1].transform.parent.parent.parent.gameObject.SetActive(true);
- });
- for (int i = 0; i < GlobalData.floorGateData.BuYuan.FloodGates.Length; i++)
- {
- GameObject floodGateDataObj = Instantiate(floodDataPrefab);
- floodGateDataObj.transform.SetParent(floodLists[0].transform);
- floodGateDataObj.transform.localScale = Vector3.one;
- floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
- floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].IsOpen ? "开启" : "关闭";
- floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentFlow + "m³/s";
- floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.CurrentWaterLevel + "m";
- floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentOpening + "°";
- switch (GlobalData.floorGateData.BuYuan.FloodGates[i].Status)
- {
- case 0:
- floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
- break;
- case 1:
- floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
- break;
- }
- }
- for (int i = 0; i < GlobalData.floorGateData.TaoKou.FloodGates.Length; i++)
- {
- GameObject floodGateDataObj = Instantiate(floodDataPrefab);
- floodGateDataObj.transform.SetParent(floodLists[1].transform);
- floodGateDataObj.transform.localScale = Vector3.one;
- floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
- floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].IsOpen ? "开启" : "关闭";
- floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentFlow + "m³/s";
- floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.CurrentWaterLevel + "m";
- floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentOpening + "°";
- switch (GlobalData.floorGateData.TaoKou.FloodGates[i].Status)
- {
- case 0:
- floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
- break;
- case 1:
- floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
- break;
- }
- }
- List<double> doubles = new List<double>();
- doubles.Add(90);
- doubles.Add(100);
- floodRingChart.UpdateData(0, 0, doubles);
- }
- private async Task InitInspectionStatistics()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.InspectionStat.Count > 0;
- });
- currentYunIndex = 0;
- yunValue1.text = GlobalData.InspectionStat[0].daily.operationStaffCount.ToString();
- yunValue2.text = GlobalData.InspectionStat[0].daily.inspectionTasksCount.ToString();
- yunValue3.text = GlobalData.InspectionStat[0].daily.inspectionKilometers.ToString();
- yunValue4.text = GlobalData.InspectionStat[0].daily.faultHazardCount.ToString();
- yunValue5.text = GlobalData.InspectionStat[0].daily.processedFaultCount.ToString();
- yunValue6.text = GlobalData.InspectionStat[0].daily.engineeringMaintenanceCount.ToString();
- yunDrop0.onValueChanged.AddListener((index) =>
- {
- currentYunIndex = index;
- SwitchStationStat(yunDrop1.value);
- });
- yunDrop1.onValueChanged.AddListener((index) =>
- {
- SwitchStationStat(index);
- });
- }
- void SwitchStationStat(int index)
- {
- switch (index)
- {
- case 0:
- yunValue1.text = GlobalData.InspectionStat[currentYunIndex].daily.operationStaffCount.ToString();
- yunValue2.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionTasksCount.ToString();
- yunValue3.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionKilometers.ToString();
- yunValue4.text = GlobalData.InspectionStat[currentYunIndex].daily.faultHazardCount.ToString();
- yunValue5.text = GlobalData.InspectionStat[currentYunIndex].daily.processedFaultCount.ToString();
- yunValue6.text = GlobalData.InspectionStat[currentYunIndex].daily.engineeringMaintenanceCount.ToString();
- break;
- case 1:
- yunValue1.text = GlobalData.InspectionStat[currentYunIndex].monthly.operationStaffCount.ToString();
- yunValue2.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionTasksCount.ToString();
- yunValue3.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionKilometers.ToString();
- yunValue4.text = GlobalData.InspectionStat[currentYunIndex].monthly.faultHazardCount.ToString();
- yunValue5.text = GlobalData.InspectionStat[currentYunIndex].monthly.processedFaultCount.ToString();
- yunValue6.text = GlobalData.InspectionStat[currentYunIndex].monthly.engineeringMaintenanceCount.ToString();
- break;
- case 2:
- yunValue1.text = GlobalData.InspectionStat[currentYunIndex].yearly.operationStaffCount.ToString();
- yunValue2.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionTasksCount.ToString();
- yunValue3.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionKilometers.ToString();
- yunValue4.text = GlobalData.InspectionStat[currentYunIndex].yearly.faultHazardCount.ToString();
- yunValue5.text = GlobalData.InspectionStat[currentYunIndex].yearly.processedFaultCount.ToString();
- yunValue6.text = GlobalData.InspectionStat[currentYunIndex].yearly.engineeringMaintenanceCount.ToString();
- break;
- }
- }
- private async Task InitLayerBtns()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.layerUnitDatas.Count > 0;
- });
- layerBtns = new List<LayerBtn>();
- for (int i = 0; i < zTLayer.layerDatas.Length; i++)
- {
- LayerBtn layerBtn = Instantiate(zTLayer.layerBtnPrefab);
- layerBtn.SetUseful(false);
- int index = i;
- int num = 0;
- if (i == 0)
- {
- List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
- for (int j = 0; j < tempDatas.Count; j++)
- {
- if (tempDatas[j].special == "1")
- {
- int tempJ = j;
- SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
- secLayerBtn.SetLayerBtnData(tempDatas[j].name);
- secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
- secLayerBtn.btn.onClick.AddListener(() =>
- {
- StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
- miniMap.gameObject.SetActive(false);
- ChangeRightContent(tempJ);
- });
- num++;
- }
- }
- layerBtn.secContent.gameObject.SetActive(true);
- }
- else
- {
- List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
- for (int j = 0; j < tempDatas.Count; j++)
- {
- Debug.Log(zTLayer.layerDatas.Length);
- Debug.Log(i);
- if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID)
- {
- int tempJ = j;
- SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
- secLayerBtn.SetLayerBtnData(tempDatas[j].name);
- secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
- secLayerBtn.btn.onClick.AddListener(() =>
- {
- StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
- miniMap.gameObject.SetActive(false);
- ChangeRightContent(tempJ);
- });
- num++;
- }
- }
- }
- layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
- {
- for (int j = 0; j < layerBtns.Count; j++)
- {
- layerBtns[j].SetUseful(false);
- layerBtns[j].secContent.gameObject.SetActive(false);
- }
- layerBtns[index].SetUseful(true);
- layerBtns[index].secContent.gameObject.SetActive(true);
- });
- layerBtn.SetLayerBtnData(zTLayer.layerSprite[zTLayer.layerDatas[i].layerID], zTLayer.layerDatas[i].layerName, num.ToString());
- layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
- layerBtn.transform.localScale = Vector3.one;
- layerBtns.Add(layerBtn);
- }
- content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
- layerBtns[0].SetUseful(true);
- }
- void ChangeRightContent(int index)
- {
- rightContent.parent.gameObject.SetActive(true);
- for (int i = 0; i < rightContent.childCount; i++)
- {
- rightContent.GetChild(i).gameObject.SetActive(false);
- }
- rightContent.GetChild(index).gameObject.SetActive(true);
- }
- // Update is called once per frame
- void Update()
- {
- znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
- }
- public async Task InitObsItems()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.obsDatas_by.Count > 0&& GlobalData.obsDatas_tk.Count>0;
- });
- for (int i = 0; i < obsItemList.Count; i++)
- {
- Destroy(obsItemList[i].gameObject);
- }
- obsItemList.Clear();
- var obsDatasBy = GlobalData.obsDatas_by;
- for (int i = 0; i < obsDatasBy.Count; i++)
- {
- var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
- tempObj.SetData(obsDatasBy[i]);
- tempObj._button.onClick.AddListener(() =>
- {
- ShowObsPanel(tempObj._data);
- });
- obsItemList.Add(tempObj);
- }
- var obsDatasTk = GlobalData.obsDatas_tk;
- for (int i = 0; i < obsDatasTk.Count; i++)
- {
- var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
- tempObj.SetData(obsDatasTk[i]);
- tempObj._button.onClick.AddListener(() =>
- {
- ShowObsPanel(tempObj._data);
- });
- obsItemList.Add(tempObj);
- }
-
- }
- public void SearchObsItem(string s_name)
- {
- if (s_name.Equals(""))
- {
- for (int i = 0; i < obsItemList.Count; i++)
- {
- obsItemList[i].gameObject.SetActive(true);
- }
- }
- else
- {
- for (int i = 0; i < obsItemList.Count; i++)
- {
- obsItemList[i].gameObject.SetActive(obsItemList[i]._data.name.Contains(s_name));
- }
- }
- }
- public void ShowObsPanel(ObsData _data)
- {
- obsPlayerPanel.gameObject.SetActive(true);
- obsPlayerPanel.SetObsData(_data);
- }
- }
|