InspectList.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using DG.Tweening;
  5. public class InspectList : MonoBehaviour
  6. {
  7. public GameObject[] button;
  8. public GameObject[] tagText;//标题文本框
  9. public List<GameObject> inspectListObjList_WaiXiang = new List<GameObject>();//外箱
  10. public List<GameObject> inspectListObjList_FuJian = new List<GameObject>();//附件
  11. public List<GameObject> inspectListObjList_PeiZhi = new List<GameObject>();//附件
  12. private GameObject inspectListObj;
  13. public GameObject listParent;
  14. public GameObject inspectListObjParent_WaiXiang;//外箱列表父级
  15. public GameObject inspectListObjParent_FuJian;//外箱列表父级
  16. public GameObject inspectListObjParent_PeiZhi;//外箱列表父级
  17. public Material tagTextMaterial1, tagTextMaterial2;//标题文本框颜色
  18. public GameObject clickFrame;//点击的 蓝色 移动框
  19. public InspectListPanel inspectListPanel;
  20. public int inspectListObjIndex_WaiXiang = 0;//命名
  21. public int inspectListObjIndex_FuJian = 0;//命名
  22. public int inspectListObjIndex_PeiZhi = 0;//命名
  23. public void Start()
  24. {
  25. StartCoroutine(LoadDll2.DownLoadAssets((AssetBundle ab) => {
  26. GameObject obj = ab.LoadAsset<GameObject>("excel_buttom");
  27. inspectListObj = obj;// Resources.Load("excel_buttom") as GameObject;
  28. }));
  29. //ShowBaseListView("WaiXiang");
  30. //MakeView_WaiXiang();
  31. //MakeView_FuJian();
  32. //MakeView_PeiZhi();
  33. }
  34. void OnDisable()
  35. {
  36. }
  37. public void UserClick(string ButtonName)
  38. {
  39. switch (ButtonName)
  40. {
  41. case "buttonTag1": //外箱
  42. ShowBaseListView("WaiXiang");
  43. clickFrame.transform.DOMove(button[0].transform.position, 0.5f);
  44. showTextTag(tagText[0]);
  45. inspectListPanel.ShowHandleClick(0);
  46. break;
  47. case "buttonTag2": //附件
  48. ShowBaseListView("FuJian");
  49. clickFrame.transform.DOMove(button[1].transform.position, 0.5f);
  50. showTextTag(tagText[1]);
  51. inspectListPanel.ShowHandleClick(5);
  52. break;
  53. case "buttonTag3": //配置
  54. ShowBaseListView("PeiZhi");
  55. showTextTag(tagText[2]);
  56. clickFrame.transform.DOMove(button[2].transform.position, 0.5f);
  57. inspectListPanel.ShowHandleClick(12);
  58. break;
  59. }
  60. }
  61. public void showTextTag(GameObject obj)
  62. {
  63. for (int i = 0; i < tagText.Length; i++)
  64. {
  65. if (tagText[i].name == obj.name)
  66. {
  67. tagText[i].transform.DOLocalMoveZ(-0.000279963f, 0.5f);
  68. tagText[i].GetComponent<MeshRenderer>().material = tagTextMaterial2;
  69. }
  70. else
  71. {
  72. tagText[i].transform.DOLocalMoveZ(0.003700018f, 0.5f);
  73. tagText[i].GetComponent<MeshRenderer>().material = tagTextMaterial1;
  74. }
  75. }
  76. }
  77. public void MakeView_WaiXiang()
  78. {
  79. for (int i = 0; i < inspectListObjList_WaiXiang.Count; i++)
  80. {
  81. inspectListObjIndex_WaiXiang++;
  82. GameObject obj = Instantiate(inspectListObj, new Vector3(inspectListObjList_WaiXiang[i].transform.position.x, inspectListObjList_WaiXiang[i].transform.position.y, 0.3526f), Quaternion.Euler(0, 0, -90));
  83. obj.transform.parent = inspectListObjParent_WaiXiang.transform;
  84. obj.name = "excel_buttom" + inspectListObjIndex_WaiXiang;
  85. inspectListPanel.taskList.Add(obj);
  86. }
  87. }
  88. public void MakeView_FuJian()
  89. {
  90. for (int i = 0; i < inspectListObjList_FuJian.Count; i++)
  91. {
  92. inspectListObjIndex_FuJian++;
  93. GameObject obj = Instantiate(inspectListObj, new Vector3(inspectListObjList_FuJian[i].transform.position.x, inspectListObjList_FuJian[i].transform.position.y, 0.3526f), Quaternion.Euler(0, 0, -90));
  94. obj.transform.parent = inspectListObjParent_FuJian.transform;
  95. obj.name = "excel_buttom" + inspectListObjIndex_FuJian;
  96. inspectListPanel.taskList.Add(obj);
  97. }
  98. }
  99. public void MakeView_PeiZhi()
  100. {
  101. for (int i = 0; i < inspectListObjList_PeiZhi.Count; i++)
  102. {
  103. inspectListObjIndex_PeiZhi++;
  104. if (inspectListObjIndex_PeiZhi <= inspectListObjList_PeiZhi.Count)
  105. {
  106. GameObject obj = Instantiate(inspectListObj, new Vector3(inspectListObjList_PeiZhi[i].transform.position.x, inspectListObjList_PeiZhi[i].transform.position.y, 0.3526f), Quaternion.Euler(0, 0, -90));
  107. obj.transform.parent = inspectListObjParent_PeiZhi.transform;
  108. obj.name = "excel_buttom" + inspectListObjIndex_PeiZhi;
  109. inspectListPanel.taskList.Add(obj);
  110. }
  111. }
  112. }
  113. public void ShowBaseListView(string str)
  114. {
  115. switch (str)
  116. {
  117. case "WaiXiang":
  118. // inspectListPanel.ShowContent(InspectListPanel.taskIndex);
  119. inspectListObjParent_WaiXiang.SetActive(true);
  120. inspectListObjParent_FuJian.SetActive(false);
  121. inspectListObjParent_PeiZhi.SetActive(false);
  122. // Invoke("Show1", 0.4f);
  123. break;
  124. case "FuJian":
  125. // inspectListPanel.ShowContent(InspectListPanel.taskIndex);
  126. inspectListObjParent_FuJian.SetActive(true);
  127. inspectListObjParent_PeiZhi.SetActive(false);
  128. inspectListObjParent_WaiXiang.SetActive(false);
  129. // Invoke("Show2", 0.4f);
  130. break;
  131. case "PeiZhi":
  132. // inspectListPanel.ShowContent(InspectListPanel.taskIndex);
  133. inspectListObjParent_PeiZhi.SetActive(true);
  134. inspectListObjParent_WaiXiang.SetActive(false);
  135. inspectListObjParent_FuJian.SetActive(false);
  136. // Invoke("Show3", 0.4f);
  137. break;
  138. }
  139. }
  140. }