InspectSettlementPanel.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class InspectSettlementPanel : MonoBehaviour
  5. {
  6. // Use this for initialization
  7. public TextMesh tagText_WaiXiang, tagTextFuJian, tagText_PeiZhi;//结果面板小标题
  8. public Transform ResultViewListParent_WaiXiang;//结果列表外箱位置
  9. public Transform WaiXiangParent;
  10. public Transform ResultViewListParent_FuJian;//结果列表附件位置
  11. public Transform FuJianParent;
  12. public Transform ResultViewListParent_PeiZhi;//结果列表配置位置
  13. public Transform PeiZhiParent;
  14. public GameObject resultView;
  15. //public ReadXMLWaiXiang readXML_WaiXiang;
  16. //public ReadXMLFuJian readXML_FuJian;
  17. //public ReadXMLPeiZhi readXML_PeiZhi;
  18. protected Transform startPos; //生成的位置
  19. public InspectListPanel inspectList;
  20. private string waiXiang = "外箱";
  21. private string fuJiang = "附件";
  22. private string peiZhi = "配置";
  23. public TextMesh EquipmentType;//设备型号
  24. public TextMesh CheckQuantity;//检查数量
  25. public TextMesh pass_Num;//检查合格通过数量
  26. public TextMesh pass_No_Num;//检查不合格数量
  27. public TextMesh player_Name;//检查人员名单
  28. public TextMesh player_WorkNumber;//检查人员工号
  29. public TextMesh CheckTimer;//检查时间
  30. private int passNum;
  31. private int passNoNum;
  32. void Start()
  33. {
  34. resultView =new GameObject() ; //Resources.Load("ResultView") as GameObject;
  35. resultView.name = "ResultView";
  36. MakeResultView();
  37. CheckQuantity.text = "检查项目: " + inspectList.taskList.Count.ToString() + " 项目";
  38. GetInspectList_ButtonPassNum();
  39. pass_Num.text = passNum.ToString();
  40. pass_Num.color = Color.green;
  41. pass_No_Num.text = passNoNum.ToString();
  42. pass_No_Num.color = Color.red;
  43. }
  44. /// <summary>
  45. /// 获取合格的数量
  46. /// </summary>
  47. void GetInspectList_ButtonPassNum()
  48. {
  49. for (int i = 0; i < inspectList.taskList.Count; i++)
  50. {
  51. if (inspectList.taskList[i].GetComponent<InspectList_Button>().status == 2)
  52. {
  53. passNum++;
  54. }
  55. else if (inspectList.taskList[i].GetComponent<InspectList_Button>().status == 3)
  56. {
  57. passNoNum++;
  58. }
  59. }
  60. }
  61. // Update is called once per frame
  62. void MakeResultView()
  63. {
  64. for (int i = 0; i < inspectList.taskList.Count; i++)
  65. {
  66. if (inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks == waiXiang)
  67. {
  68. if (WaiXiangParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text) == null)
  69. {
  70. startPos = ResultViewListParent_WaiXiang.Find(inspectList.taskList[i].GetComponent<InspectList_Button>().endResultViewPos).gameObject.transform;
  71. GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
  72. obj.transform.parent = WaiXiangParent.transform;
  73. obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
  74. obj.name = "ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text;
  75. obj.GetComponent<inspectResultList_Button>().SetText_ID(inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text);
  76. obj.GetComponent<inspectResultList_Button>().SetText_Tag(inspectList.taskList[i].GetComponent<InspectList_Button>().text_name.text);
  77. obj.GetComponent<inspectResultList_Button>().SetText_Status(inspectList.taskList[i].GetComponent<InspectList_Button>().startInspect);
  78. tagText_WaiXiang.text = inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks + "检查结果";
  79. }
  80. }
  81. if (inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks == fuJiang)
  82. {
  83. if (FuJianParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text) == null)
  84. {
  85. startPos = ResultViewListParent_FuJian.Find(inspectList.taskList[i].GetComponent<InspectList_Button>().endResultViewPos).gameObject.transform;
  86. GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
  87. obj.transform.parent = FuJianParent.transform;
  88. obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
  89. obj.name = "ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text;
  90. obj.GetComponent<inspectResultList_Button>().SetText_ID(inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text);
  91. obj.GetComponent<inspectResultList_Button>().SetText_Tag(inspectList.taskList[i].GetComponent<InspectList_Button>().text_name.text);
  92. obj.GetComponent<inspectResultList_Button>().SetText_Status(inspectList.taskList[i].GetComponent<InspectList_Button>().startInspect);
  93. tagTextFuJian.text = inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks + "检查结果";
  94. }
  95. }
  96. if (inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks == peiZhi)
  97. {
  98. if (PeiZhiParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text) == null)
  99. {
  100. tagText_PeiZhi.text = inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks + "检查结果";
  101. startPos = ResultViewListParent_PeiZhi.Find(inspectList.taskList[i].GetComponent<InspectList_Button>().endResultViewPos).gameObject.transform;
  102. GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
  103. obj.transform.parent = PeiZhiParent.transform;
  104. obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
  105. obj.name = "ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text;
  106. obj.GetComponent<inspectResultList_Button>().SetText_ID(inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text);
  107. obj.GetComponent<inspectResultList_Button>().SetText_Tag(inspectList.taskList[i].GetComponent<InspectList_Button>().text_name.text);
  108. obj.GetComponent<inspectResultList_Button>().SetText_Status(inspectList.taskList[i].GetComponent<InspectList_Button>().startInspect);
  109. }
  110. }
  111. }
  112. }
  113. }