JinRuRenwu.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using XRTool.Util;
  7. using static XunJianDataManager;
  8. public class JinRuRenwu : MonoBehaviour
  9. {
  10. RenWuItem rwitem;
  11. public GameObject WenJianLan;
  12. public TextMeshProUGUI info;
  13. public GameObject TaskGo;
  14. public GameObject PaiZhaoGo;
  15. public GameObject VideoBT;
  16. public GameObject ModelBT;
  17. public GameObject ImageBT;
  18. public GameObject Image2BT;
  19. public GameObject TextBT;
  20. public GameObject AllBT;
  21. public GameObject Video;
  22. public GameObject Model;
  23. public GameObject Image;
  24. public GameObject Image2;
  25. public GameObject Text;
  26. public List<GameObject> updateList;
  27. public GameObject kong;
  28. private void OnEnable()
  29. {
  30. //RoadManager.Instance.gameObject.SetActive(true);
  31. updateListRef();
  32. TimerMgr.Instance.CreateTimer(()=> {
  33. kong.SetActive(!kong.activeSelf);
  34. },0.01f,6);
  35. if(XunJianDataManager.Instance.chooseXunJian!=null)
  36. updateData();
  37. }
  38. void updateData()
  39. {
  40. VideoBT.SetActive(false);
  41. ModelBT.SetActive(false);
  42. ImageBT.SetActive(false);
  43. Image2BT.SetActive(false);
  44. TextBT.SetActive(false);
  45. rwitem = XunJianDataManager.Instance.GetRenWuItem(XunJianDataManager.Instance.chooseXunJian.itemList[XunJianDataManager.Instance.chooseXunJian.nowIndex]);
  46. info.text = rwitem.info;
  47. if (rwitem.typeList.Count > 0)
  48. {
  49. int img = 0;
  50. for (int i = 0; i < rwitem.typeList.Count; i++)
  51. {
  52. switch (rwitem.typeList[i].type)
  53. {
  54. case RenWuType.Image:
  55. if(img==0)
  56. {
  57. ImageBT.SetActive(true);
  58. Image.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  59. }
  60. else
  61. {
  62. Image2BT.SetActive(false);
  63. Image2.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  64. }
  65. img++;
  66. break;
  67. case RenWuType.Model:
  68. ModelBT.SetActive(true);
  69. Model.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  70. break;
  71. case RenWuType.Text:
  72. TextBT.SetActive(true);
  73. Text.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  74. break;
  75. case RenWuType.Video:
  76. VideoBT.SetActive(true);
  77. Video.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  78. break;
  79. }
  80. }
  81. if(rwitem.typeList.Count < 2)
  82. {
  83. AllBT.SetActive(false);
  84. }else
  85. {
  86. AllBT.SetActive(true);
  87. }
  88. WenJianLan.SetActive(true);
  89. }
  90. else
  91. {
  92. WenJianLan.SetActive(false);
  93. }
  94. }
  95. private void OnDisable()
  96. {
  97. //RoadManager.Instance.gameObject.SetActive(false);
  98. }
  99. public void showAll()
  100. {
  101. Text.SetActive(true);
  102. Image.SetActive(true);
  103. Image2.SetActive(true);
  104. Model.SetActive(true);
  105. Video.SetActive(true);
  106. PaiZhaoGo.SetActive(true);
  107. }
  108. public void showText()
  109. {
  110. Text.SetActive(!Text.activeSelf);
  111. Text.transform.SetAsFirstSibling();
  112. }
  113. public void showImage()
  114. {
  115. Image.SetActive(!Image.activeSelf);
  116. Image.transform.SetAsFirstSibling();
  117. }
  118. public void showImage2()
  119. {
  120. Image2.SetActive(!Image2.activeSelf);
  121. Image2.transform.SetAsFirstSibling();
  122. }
  123. public void showModel()
  124. {
  125. Model.SetActive(!Model.activeSelf);
  126. Model.transform.SetAsFirstSibling();
  127. }
  128. public void showVideo()
  129. {
  130. Video.SetActive(!Video.activeSelf);
  131. Video.transform.SetAsFirstSibling();
  132. }
  133. public void GotoPaiZhao()
  134. {
  135. PaiZhaoGo.SetActive(!PaiZhaoGo.activeSelf);
  136. }
  137. public void GotoTask()
  138. {
  139. TaskGo.SetActive(!TaskGo.activeSelf);
  140. }
  141. public void GotoLieBiao()
  142. {
  143. ProjectMainWindow.Instance.showXunJian();
  144. }
  145. public void updateListRef()
  146. {
  147. for (int i = updateList.Count-1; i >=0; i--)
  148. {
  149. if ((updateList[i].GetComponent<ContentSizeFitter>()))
  150. {
  151. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutVertical();
  152. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutHorizontal();
  153. }
  154. if (updateList[i].GetComponent<HorizontalLayoutGroup>())
  155. {
  156. updateList[i].GetComponent<HorizontalLayoutGroup>().SetLayoutHorizontal();
  157. updateList[i].GetComponent<HorizontalLayoutGroup>().CalculateLayoutInputHorizontal();
  158. }
  159. if ((updateList[i].GetComponent<VerticalLayoutGroup>()))
  160. {
  161. updateList[i].GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  162. updateList[i].GetComponent<VerticalLayoutGroup>().CalculateLayoutInputVertical();
  163. }
  164. }
  165. }
  166. }