123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using UnityEngine;
- using UnityAsync;
- using WaitUntil = UnityAsync.WaitUntil;
- using System.Threading.Tasks;
- using UnityEngine.UI;
- public class GCZLLayer : MonoBehaviour
- {
- public GameObject classPrefab;
- public GameObject informationPrefab;
- public RectTransform classContent;
- public RectTransform informationContent;
- public InputField informationSearchInput;
- public YZTLayer zTLayer;
- public Sprite[] sprites;
- private List<GameObject> informations = new List<GameObject>();
- private GameObject lastClassBtn;
- private int currentClass = -99;
- private GameObject InfoPanel;
- private Button InfoExitButton;
- private Button Info_DetailButton;
- private Text InfoTitleText;
- private Text InfoClassText;
- private Text InfoNoText;
- private Text InfoDayText;
- private RawImage InfoFM;
- private GameObject DetailPanel;
- private Button DetailExitButton;
- private Text DetailTitleText;
- private LayerUnitData currentData;
- //private Button OpenAniButton;
- //private Button CloseAniButton;
- private Button detail_modelButton;
- private Button detail_designButton;
- private Button detail_photoButton;
- private Button detail_videoButton;
- private CanvasGroup detail_modelCG;
- private CanvasGroup detail_designCG;
- private CanvasGroup detail_photoCG;
- private CanvasGroup detail_videoCG;
- private RawImage showFrame;
- private Button lastPhotoButton;
- private Button nextPhotoButton;
- public RenderTexture modelRT;
- public string[] BY_PhotoUrl;
- public string[] TK_PhotoUrl;
- public int photoIndex;
- public string[] BY_PdfUrl;
- public string[] TK_PdfUrl;
- public int pdfIndex;
- public string[] BY_PdfDownloadUrl;
- public string[] TK_PdfDownloadUrl;
- private Button downloadPdfButton;
- private int showTypeIndex = 0;
-
- [DllImport("__Internal")]
- private static extern void OpenNewWebsite(string str);
- private void Awake()
- {
-
- InfoPanel = this.transform.Find("InfoPanel").gameObject;
- InfoTitleText = InfoPanel.transform.Find("Title").GetComponent<Text>();
- InfoClassText = InfoPanel.transform.Find("Class").GetComponent<Text>();
- InfoNoText = InfoPanel.transform.Find("No").GetComponent<Text>();
- InfoDayText = InfoPanel.transform.Find("Day").GetComponent<Text>();
- InfoFM = InfoPanel.transform.Find("fm").GetComponent<RawImage>();
- InfoExitButton = InfoPanel.transform.Find("CloseButton").GetComponent<Button>();
- InfoExitButton.onClick.AddListener(() => { InfoPanel.SetActive(false); });
- Info_DetailButton = InfoPanel.transform.Find("MoreButton").GetComponent<Button>();
- Info_DetailButton.onClick.AddListener(() =>
- {
- DetailTitleText.text = currentData.name;
- // OpenAniButton.gameObject.SetActive(currentData.namePri.Equals("BuYuan") ||
- // currentData.namePri.Equals("TaoKou"));
- // CloseAniButton.gameObject.SetActive(currentData.namePri.Equals("BuYuan") ||
- // currentData.namePri.Equals("TaoKou"));
- ModelCameraCtrl._Instance.SetCameraActive(true);
- ResetDetailPanel();
- DetailPanel.SetActive(true);
- });
- DetailPanel = this.transform.Find("DetailPanel").gameObject;
-
-
- DetailTitleText = DetailPanel.transform.Find("Title").GetComponent<Text>();
- DetailExitButton = DetailPanel.transform.Find("CloseButton").GetComponent<Button>();
- DetailExitButton.onClick.AddListener(() =>
- {
- DetailPanel.SetActive(false);
- ModelCameraCtrl._Instance.SetCameraActive(false);
- });
- detail_modelButton = DetailPanel.transform.Find("ModelButton").GetComponent<Button>();
- detail_designButton = DetailPanel.transform.Find("DesignButton").GetComponent<Button>();
- detail_photoButton = DetailPanel.transform.Find("PhotoButton").GetComponent<Button>();
- detail_videoButton = DetailPanel.transform.Find("VideoButton").GetComponent<Button>();
- detail_modelCG = detail_modelButton.GetComponent<CanvasGroup>();
- detail_designCG = detail_designButton.GetComponent<CanvasGroup>();
- detail_photoCG = detail_photoButton.GetComponent<CanvasGroup>();
- detail_videoCG = detail_videoButton.GetComponent<CanvasGroup>();
- detail_modelButton.onClick.AddListener(() => { DetailShowType(0); });
- detail_designButton.onClick.AddListener(() => { DetailShowType(1); });
- detail_photoButton.onClick.AddListener(() => { DetailShowType(2); });
- detail_videoButton.onClick.AddListener(() => { DetailShowType(3); });
- showFrame = DetailPanel.transform.Find("ShowFrame").GetComponent<RawImage>();
- showFrame.texture = modelRT;
- lastPhotoButton = DetailPanel.transform.Find("LastPhotoButton").GetComponent<Button>();
- lastPhotoButton.onClick.AddListener(()=>
- {
- switch (showTypeIndex)
- {
- case 1:
- ChangePDF((-1));
- break;
- case 2:
- ChangePhoto(-1);
- break;
- }
- });
- nextPhotoButton = DetailPanel.transform.Find("NextPhotoButton").GetComponent<Button>();
- nextPhotoButton.onClick.AddListener(()=>
- {
- switch (showTypeIndex)
- {
- case 1:
- ChangePDF((1));
- break;
- case 2:
- ChangePhoto(1);
- break;
- }
- });
- downloadPdfButton = DetailPanel.transform.Find("DownButton").GetComponent<Button>();
- downloadPdfButton.onClick.AddListener(DownLoadPDF);
-
- // OpenAniButton = DetailPanel.transform.Find("OpenAniButton").GetComponent<Button>();
- // OpenAniButton.onClick.AddListener(() =>
- // {
- // float[] openValues=new float[1];
- // if (currentData.namePri.Equals("BuYuan"))
- // {
- // openValues=new float[GlobalData.buYuanSensorData.data.Count];
- // for (int i = 0; i < openValues.Length; i++)
- // {
- // openValues[i] = GlobalData.buYuanSensorData.data[i].opening_degree*0.01f;
- // }
- // }
- // if (currentData.namePri.Equals("TaoKou"))
- // {
- // openValues=new float[GlobalData.taoKouSensorData.data.Count];
- // for (int i = 0; i < openValues.Length; i++)
- // {
- // openValues[i] = GlobalData.taoKouSensorData.data[i].opening_degree*0.01f;
- // }
- // }
- // ActionInstance._Instance.ModelAni_On?.Invoke(openValues);
- // });
- // CloseAniButton = DetailPanel.transform.Find("CloseAniButton").GetComponent<Button>();
- // CloseAniButton.onClick.AddListener(() => { ActionInstance._Instance.ModelAni_Off?.Invoke(); });
- InfoPanel.SetActive(false);
- DetailPanel.SetActive(false);
- }
- // Start is called before the first frame update
- async void Start()
- {
- await InitData();
- //StaticLod.instance.OnFoucusStatic(0);
- CameraManager.SwitchCamera(0);
- InitButton();
- InitInformation(0);
-
- informationSearchInput.onValueChanged.AddListener(SearchInformationItem);
- }
- void InitButton()
- {
- for (int i = 0; i < zTLayer.layerDatas.Length; i++)
- {
- string name = zTLayer.layerDatas[i].layerName;
- int temp = i;
- GameObject obj = Instantiate(classPrefab);
- obj.transform.SetParent(classContent);
- obj.GetComponentInChildren<Text>().text = name;
- obj.transform.localScale = Vector3.one;
- if (i == 0)
- {
- obj.GetComponent<Image>().sprite = sprites[0];
- lastClassBtn = obj;
- }
- else
- {
- obj.GetComponent<Image>().sprite = sprites[1];
- }
- obj.GetComponent<Button>().onClick.AddListener(() =>
- {
- InitInformation(temp);
- lastClassBtn.GetComponent<Image>().sprite = sprites[1];
- obj.GetComponent<Image>().sprite = sprites[0];
- lastClassBtn = obj;
- });
- }
- }
- void InitInformation(int index)
- {
- if (currentClass == index) return;
- for (int i = informations.Count - 1; i >= 0; i--)
- {
- Destroy(informations[i]);
- }
- informations.Clear();
- currentClass = index;
- if (currentClass == 0)
- {
- for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
- {
- if (GlobalData.layerUnitDatas[i].special == "1")
- {
- GameObject obj = Instantiate(informationPrefab);
- string realName = GlobalData.layerUnitDatas[i].name;
- string priName = GlobalData.layerUnitDatas[i].namePri;
- priName = priName.Replace("TaoKou", "NewTaoKou");
- var objType = GlobalData.layerUnitDatas[i].type;
- string className = GlobalData.layerUnitDatas[i].GetTypeName();
- obj.transform.SetParent(informationContent);
- obj.transform.Find("Name").GetComponentInChildren<Text>().text = realName;
- obj.transform.Find("Class").GetComponentInChildren<Text>().text = className;
- //todo
- obj.transform.Find("No").GetComponentInChildren<Text>().text = "未知";
- obj.transform.Find("Day").GetComponentInChildren<Text>().text = "近期";
- obj.transform.Find("fm").GetComponent<RawImage>().texture =
- TextureLoadHelp._Instance.GetTempTexture(priName);
- obj.transform.localScale = Vector3.one;
- informations.Add(obj);
- int dataIndex = i;
- obj.GetComponent<Button>().onClick.AddListener(() =>
- {
- currentData = GlobalData.layerUnitDatas[dataIndex];
- StaticLod.instance.OnFoucusStatic(priName);
- if (objType == LayerUnitType.ZZ || objType == LayerUnitType.BZ)
- {
- Info_DetailButton.gameObject.SetActive(true);
- }
- else
- {
- Info_DetailButton.gameObject.SetActive(false);
- }
- ShowInfoPanelData();
- });
- }
- }
- }
- else
- {
- for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
- {
- if (GlobalData.layerUnitDatas[i].type == (LayerUnitType)currentClass)
- {
- GameObject obj = Instantiate(informationPrefab);
- string realName = GlobalData.layerUnitDatas[i].name;
- string priName = GlobalData.layerUnitDatas[i].namePri;
- var objType = GlobalData.layerUnitDatas[i].type;
- string className = GlobalData.layerUnitDatas[i].GetTypeName();
- obj.transform.SetParent(informationContent);
- obj.transform.Find("Name").GetComponentInChildren<Text>().text = realName;
- obj.transform.Find("Class").GetComponentInChildren<Text>().text = className;
- //todo
- obj.transform.Find("No").GetComponentInChildren<Text>().text = "未知";
- obj.transform.Find("Day").GetComponentInChildren<Text>().text = "近期";
- obj.transform.Find("fm").GetComponent<RawImage>().texture =
- TextureLoadHelp._Instance.GetTempTexture(priName);
- obj.transform.localScale = Vector3.one;
- informations.Add(obj);
- int dataIndex = i;
- obj.GetComponent<Button>().onClick.AddListener(() =>
- {
- currentData = GlobalData.layerUnitDatas[dataIndex];
- StaticLod.instance.OnFoucusStatic(priName);
- if (objType == LayerUnitType.ZZ || objType == LayerUnitType.BZ)
- {
- Info_DetailButton.gameObject.SetActive(true);
- }
- else
- {
- Info_DetailButton.gameObject.SetActive(false);
- }
- ShowInfoPanelData();
- });
- }
- }
- }
- }
-
- public void SearchInformationItem(string s_name)
- {
- if (s_name.Equals(""))
- {
- for (int i = 0; i < informations.Count; i++)
- {
- informations[i].gameObject.SetActive(true);
- }
- }
- else
- {
- for (int i = 0; i < informations.Count; i++)
- {
- informations[i].gameObject.SetActive(informations[i].transform.Find("Name").GetComponentInChildren<Text>().text.Contains(s_name));
- }
- }
- }
- async Task InitData()
- {
- await new WaitUntil(() => { return GlobalData.layerUnitDatas.Count > 0; });
- }
- public void ShowInfoPanelData()
- {
- InfoTitleText.text = currentData.name;
- InfoClassText.text = currentData.GetTypeName();
- InfoFM.texture = TextureLoadHelp._Instance.GetTempTexture(currentData.namePri);
- //todo
- InfoNoText.text = "未知";
- InfoDayText.text = "近期";
- InfoPanel.SetActive(true);
- }
- public void ResetDetailPanel()
- {
- photoIndex = 0;
- pdfIndex = 0;
- lastPhotoButton.gameObject.SetActive(false);
- nextPhotoButton.gameObject.SetActive(false);
- downloadPdfButton.gameObject.SetActive(false);
- DetailShowType(0);
- }
- public void DetailShowType(int index)
- {
- showTypeIndex = index;
- switch (index)
- {
- case 0:
- detail_modelCG.alpha = 1;
- detail_designCG.alpha = 0.6f;
- detail_photoCG.alpha = 0.6f;
- detail_videoCG.alpha = 0.6f;
- showFrame.texture = modelRT;
- lastPhotoButton.gameObject.SetActive(false);
- nextPhotoButton.gameObject.SetActive(false);
-
-
- // OpenAniButton.gameObject.SetActive(currentData.namePri.Equals("BuYuan") ||
- // currentData.namePri.Equals("TaoKou"));
- // CloseAniButton.gameObject.SetActive(currentData.namePri.Equals("BuYuan") ||
- // currentData.namePri.Equals("TaoKou"));
- downloadPdfButton.gameObject.SetActive(false);
- break;
- case 1:
- detail_modelCG.alpha = 0.6f;
- detail_designCG.alpha = 1f;
- detail_photoCG.alpha = 0.6f;
- detail_videoCG.alpha = 0.6f;
- showFrame.texture = null;
- lastPhotoButton.gameObject.SetActive(true);
- nextPhotoButton.gameObject.SetActive(true);
-
- // OpenAniButton.gameObject.SetActive(false);
- // CloseAniButton.gameObject.SetActive(false);
- ChangePDF(0);
- break;
- case 2:
- detail_modelCG.alpha = 0.6f;
- detail_designCG.alpha = 0.6f;
- detail_photoCG.alpha = 1f;
- detail_videoCG.alpha = 0.6f;
- showFrame.texture = null;
- lastPhotoButton.gameObject.SetActive(true);
- nextPhotoButton.gameObject.SetActive(true);
- // OpenAniButton.gameObject.SetActive(false);
- // CloseAniButton.gameObject.SetActive(false);
- downloadPdfButton.gameObject.SetActive(false);
- ChangePhoto(0);
- break;
- case 3:
- detail_modelCG.alpha = 0.6f;
- detail_designCG.alpha = 0.6f;
- detail_photoCG.alpha = 0.6f;
- detail_videoCG.alpha = 1f;
- showFrame.texture = null;
- lastPhotoButton.gameObject.SetActive(false);
- nextPhotoButton.gameObject.SetActive(false);
-
- // OpenAniButton.gameObject.SetActive(false);
- // CloseAniButton.gameObject.SetActive(false);
- downloadPdfButton.gameObject.SetActive(false);
- break;
- }
- }
- public void ChangePhoto(int moveIndex)
- {
- if (currentData.namePri.Equals("BuYuan"))
- {
- switch (moveIndex)
- {
- case -1:
- if (photoIndex - 1 >= 0)
- {
- photoIndex--;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + BY_PhotoUrl[photoIndex], showFrame);
- }
- break;
- case 0:
- photoIndex = 0;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + BY_PhotoUrl[photoIndex], showFrame);
- break;
- case 1:
- if (photoIndex + 1 <= BY_PhotoUrl.Length-1)
- {
- photoIndex++;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + BY_PhotoUrl[photoIndex], showFrame);
- }
- break;
- }
- }
- if (currentData.namePri.Equals("TaoKou"))
- {
- switch (moveIndex)
- {
- case -1:
- if (photoIndex - 1 >= 0)
- {
- photoIndex--;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + TK_PhotoUrl[photoIndex], showFrame);
- }
- break;
- case 0:
- photoIndex = 0;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + TK_PhotoUrl[photoIndex], showFrame);
- break;
- case 1:
- if (photoIndex + 1 <= TK_PhotoUrl.Length-1)
- {
- photoIndex++;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + TK_PhotoUrl[photoIndex], showFrame);
- }
- break;
- }
- }
- }
-
-
- public void ChangePDF(int moveIndex)
- {
- if (currentData.namePri.Equals("BuYuan"))
- {
- switch (moveIndex)
- {
- case -1:
- if (pdfIndex - 1 >= 0)
- {
- pdfIndex--;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + BY_PdfUrl[pdfIndex], showFrame);
- }
- break;
- case 0:
- downloadPdfButton.gameObject.SetActive(true);
- pdfIndex = 0;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + BY_PdfUrl[pdfIndex], showFrame);
- break;
- case 1:
- if (pdfIndex + 1 <= BY_PdfUrl.Length-1)
- {
- pdfIndex++;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + BY_PdfUrl[pdfIndex], showFrame);
- }
- break;
- }
- }
- if (currentData.namePri.Equals("TaoKou"))
- {
- switch (moveIndex)
- {
- case -1:
- if (pdfIndex - 1 >= 0)
- {
- pdfIndex--;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + TK_PdfUrl[pdfIndex], showFrame);
- }
- break;
- case 0:
- downloadPdfButton.gameObject.SetActive(true);
- pdfIndex = 0;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + TK_PdfUrl[pdfIndex], showFrame);
- break;
- case 1:
- if (pdfIndex + 1 <= TK_PdfUrl.Length-1)
- {
- pdfIndex++;
- TextureLoadHelp._Instance.LoadTexFromUrl(ServerAddress.Server_UploadPath + TK_PdfUrl[pdfIndex], showFrame);
- }
- break;
- }
- }
- }
- public void DownLoadPDF()
- {
- if (currentData.namePri.Equals("BuYuan"))
- {
- for (int i = 0; i < BY_PdfDownloadUrl.Length; i++)
- {
- OpenNewWebsite(ServerAddress.Server_UploadPath + BY_PdfDownloadUrl[i]);
- }
- }
- if (currentData.namePri.Equals("TaoKou"))
- {
- for (int i = 0; i < TK_PdfDownloadUrl.Length; i++)
- {
- OpenNewWebsite(ServerAddress.Server_UploadPath + TK_PdfDownloadUrl[i]);
- }
- }
- }
- }
|