123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using static XunJianDataManager;
- public class JinRuRenwu : MonoBehaviour
- {
- RenWuItem rwitem;
- public GameObject WenJianLan;
- public TextMeshProUGUI info;
- public GameObject TaskGo;
- public GameObject PaiZhaoGo;
- public GameObject VideoBT;
- public GameObject ModelBT;
- public GameObject ImageBT;
- public GameObject Image2BT;
- public GameObject TextBT;
- public GameObject AllBT;
- public GameObject Video;
- public GameObject Model;
- public GameObject Image;
- public GameObject Image2;
- public GameObject Text;
- public List<GameObject> updateList;
- public GameObject kong;
- private void OnEnable()
- {
-
- updateListRef();
- TimerMgr.Instance.CreateTimer(()=> {
- kong.SetActive(!kong.activeSelf);
- },0.01f,6);
- if(XunJianDataManager.Instance.chooseXunJian!=null)
- updateData();
- }
- void updateData()
- {
- VideoBT.SetActive(false);
- ModelBT.SetActive(false);
- ImageBT.SetActive(false);
- Image2BT.SetActive(false);
- TextBT.SetActive(false);
- rwitem = XunJianDataManager.Instance.GetRenWuItem(XunJianDataManager.Instance.chooseXunJian.itemList[XunJianDataManager.Instance.chooseXunJian.nowIndex]);
- info.text = rwitem.info;
- if (rwitem.typeList.Count > 0)
- {
- int img = 0;
- for (int i = 0; i < rwitem.typeList.Count; i++)
- {
- switch (rwitem.typeList[i].type)
- {
- case RenWuType.Image:
- if(img==0)
- {
- ImageBT.SetActive(true);
- Image.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
- }
- else
- {
- Image2BT.SetActive(false);
- Image2.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
- }
- img++;
- break;
- case RenWuType.Model:
- ModelBT.SetActive(true);
- Model.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
- break;
- case RenWuType.Text:
- TextBT.SetActive(true);
- Text.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
- break;
- case RenWuType.Video:
- VideoBT.SetActive(true);
- Video.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
- break;
- }
- }
- if(rwitem.typeList.Count < 2)
- {
- AllBT.SetActive(false);
- }else
- {
- AllBT.SetActive(true);
- }
- WenJianLan.SetActive(true);
- }
- else
- {
- WenJianLan.SetActive(false);
- }
- }
- private void OnDisable()
- {
-
- }
- public void showAll()
- {
- Text.SetActive(true);
- Image.SetActive(true);
- Image2.SetActive(true);
- Model.SetActive(true);
- Video.SetActive(true);
- PaiZhaoGo.SetActive(true);
- }
- public void showText()
- {
- Text.SetActive(!Text.activeSelf);
- Text.transform.SetAsFirstSibling();
- }
- public void showImage()
- {
- Image.SetActive(!Image.activeSelf);
- Image.transform.SetAsFirstSibling();
- }
- public void showImage2()
- {
- Image2.SetActive(!Image2.activeSelf);
- Image2.transform.SetAsFirstSibling();
- }
- public void showModel()
- {
- Model.SetActive(!Model.activeSelf);
- Model.transform.SetAsFirstSibling();
- }
- public void showVideo()
- {
- Video.SetActive(!Video.activeSelf);
- Video.transform.SetAsFirstSibling();
- }
- public void GotoPaiZhao()
- {
- PaiZhaoGo.SetActive(!PaiZhaoGo.activeSelf);
- }
- public void GotoTask()
- {
- TaskGo.SetActive(!TaskGo.activeSelf);
- }
- public void GotoLieBiao()
- {
- ProjectMainWindow.Instance.showXunJian();
- }
- public void updateListRef()
- {
- for (int i = updateList.Count-1; i >=0; i--)
- {
- if ((updateList[i].GetComponent<ContentSizeFitter>()))
- {
- updateList[i].GetComponent<ContentSizeFitter>().SetLayoutVertical();
- updateList[i].GetComponent<ContentSizeFitter>().SetLayoutHorizontal();
- }
- if (updateList[i].GetComponent<HorizontalLayoutGroup>())
- {
- updateList[i].GetComponent<HorizontalLayoutGroup>().SetLayoutHorizontal();
- updateList[i].GetComponent<HorizontalLayoutGroup>().CalculateLayoutInputHorizontal();
- }
- if ((updateList[i].GetComponent<VerticalLayoutGroup>()))
- {
- updateList[i].GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
- updateList[i].GetComponent<VerticalLayoutGroup>().CalculateLayoutInputVertical();
- }
- }
- }
- }
|