InspectList.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. inspectListObj = Resources.Load("excel_buttom") as GameObject;
  26. //ShowBaseListView("WaiXiang");
  27. //MakeView_WaiXiang();
  28. //MakeView_FuJian();
  29. //MakeView_PeiZhi();
  30. }
  31. void OnDisable()
  32. {
  33. }
  34. public void UserClick(string ButtonName)
  35. {
  36. switch (ButtonName)
  37. {
  38. case "buttonTag1": //外箱
  39. ShowBaseListView("WaiXiang");
  40. clickFrame.transform.DOMove(button[0].transform.position, 0.5f);
  41. showTextTag(tagText[0]);
  42. inspectListPanel.ShowHandleClick(0);
  43. break;
  44. case "buttonTag2": //附件
  45. ShowBaseListView("FuJian");
  46. clickFrame.transform.DOMove(button[1].transform.position, 0.5f);
  47. showTextTag(tagText[1]);
  48. inspectListPanel.ShowHandleClick(5);
  49. break;
  50. case "buttonTag3": //配置
  51. ShowBaseListView("PeiZhi");
  52. showTextTag(tagText[2]);
  53. clickFrame.transform.DOMove(button[2].transform.position, 0.5f);
  54. inspectListPanel.ShowHandleClick(12);
  55. break;
  56. }
  57. }
  58. public void showTextTag(GameObject obj)
  59. {
  60. for (int i = 0; i < tagText.Length; i++)
  61. {
  62. if (tagText[i].name == obj.name)
  63. {
  64. tagText[i].transform.DOLocalMoveZ(-0.000279963f, 0.5f);
  65. tagText[i].GetComponent<MeshRenderer>().material = tagTextMaterial2;
  66. }
  67. else
  68. {
  69. tagText[i].transform.DOLocalMoveZ(0.003700018f, 0.5f);
  70. tagText[i].GetComponent<MeshRenderer>().material = tagTextMaterial1;
  71. }
  72. }
  73. }
  74. public void MakeView_WaiXiang()
  75. {
  76. for (int i = 0; i < inspectListObjList_WaiXiang.Count; i++)
  77. {
  78. inspectListObjIndex_WaiXiang++;
  79. 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));
  80. obj.transform.parent = inspectListObjParent_WaiXiang.transform;
  81. obj.name = "excel_buttom" + inspectListObjIndex_WaiXiang;
  82. inspectListPanel.taskList.Add(obj);
  83. }
  84. }
  85. public void MakeView_FuJian()
  86. {
  87. for (int i = 0; i < inspectListObjList_FuJian.Count; i++)
  88. {
  89. inspectListObjIndex_FuJian++;
  90. 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));
  91. obj.transform.parent = inspectListObjParent_FuJian.transform;
  92. obj.name = "excel_buttom" + inspectListObjIndex_FuJian;
  93. inspectListPanel.taskList.Add(obj);
  94. }
  95. }
  96. public void MakeView_PeiZhi()
  97. {
  98. for (int i = 0; i < inspectListObjList_PeiZhi.Count; i++)
  99. {
  100. inspectListObjIndex_PeiZhi++;
  101. if (inspectListObjIndex_PeiZhi <= inspectListObjList_PeiZhi.Count)
  102. {
  103. 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));
  104. obj.transform.parent = inspectListObjParent_PeiZhi.transform;
  105. obj.name = "excel_buttom" + inspectListObjIndex_PeiZhi;
  106. inspectListPanel.taskList.Add(obj);
  107. }
  108. }
  109. }
  110. public void ShowBaseListView(string str)
  111. {
  112. switch (str)
  113. {
  114. case "WaiXiang":
  115. // inspectListPanel.ShowContent(InspectListPanel.taskIndex);
  116. inspectListObjParent_WaiXiang.SetActive(true);
  117. inspectListObjParent_FuJian.SetActive(false);
  118. inspectListObjParent_PeiZhi.SetActive(false);
  119. // Invoke("Show1", 0.4f);
  120. break;
  121. case "FuJian":
  122. // inspectListPanel.ShowContent(InspectListPanel.taskIndex);
  123. inspectListObjParent_FuJian.SetActive(true);
  124. inspectListObjParent_PeiZhi.SetActive(false);
  125. inspectListObjParent_WaiXiang.SetActive(false);
  126. // Invoke("Show2", 0.4f);
  127. break;
  128. case "PeiZhi":
  129. // inspectListPanel.ShowContent(InspectListPanel.taskIndex);
  130. inspectListObjParent_PeiZhi.SetActive(true);
  131. inspectListObjParent_WaiXiang.SetActive(false);
  132. inspectListObjParent_FuJian.SetActive(false);
  133. // Invoke("Show3", 0.4f);
  134. break;
  135. }
  136. }
  137. }