InspectSettlementPanel.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 = Resources.Load("ResultView") as GameObject;
  35. MakeResultView();
  36. CheckQuantity.text = "检查项目: " + inspectList.taskList.Count.ToString() + " 项目";
  37. GetInspectList_ButtonPassNum();
  38. pass_Num.text = passNum.ToString();
  39. pass_Num.color = Color.green;
  40. pass_No_Num.text = passNoNum.ToString();
  41. pass_No_Num.color = Color.red;
  42. }
  43. /// <summary>
  44. /// 获取合格的数量
  45. /// </summary>
  46. void GetInspectList_ButtonPassNum()
  47. {
  48. for (int i = 0; i < inspectList.taskList.Count; i++)
  49. {
  50. if (inspectList.taskList[i].GetComponent<InspectList_Button>().status == 2)
  51. {
  52. passNum++;
  53. }
  54. else if (inspectList.taskList[i].GetComponent<InspectList_Button>().status == 3)
  55. {
  56. passNoNum++;
  57. }
  58. }
  59. }
  60. // Update is called once per frame
  61. void MakeResultView()
  62. {
  63. for (int i = 0; i < inspectList.taskList.Count; i++)
  64. {
  65. if (inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks == waiXiang)
  66. {
  67. if (WaiXiangParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text) == null)
  68. {
  69. startPos = ResultViewListParent_WaiXiang.Find(inspectList.taskList[i].GetComponent<InspectList_Button>().endResultViewPos).gameObject.transform;
  70. GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
  71. obj.transform.parent = WaiXiangParent.transform;
  72. obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
  73. obj.name = "ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text;
  74. obj.GetComponent<inspectResultList_Button>().SetText_ID(inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text);
  75. obj.GetComponent<inspectResultList_Button>().SetText_Tag(inspectList.taskList[i].GetComponent<InspectList_Button>().text_name.text);
  76. obj.GetComponent<inspectResultList_Button>().SetText_Status(inspectList.taskList[i].GetComponent<InspectList_Button>().startInspect);
  77. tagText_WaiXiang.text = inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks + "检查结果";
  78. }
  79. }
  80. if (inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks == fuJiang)
  81. {
  82. if (FuJianParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text) == null)
  83. {
  84. startPos = ResultViewListParent_FuJian.Find(inspectList.taskList[i].GetComponent<InspectList_Button>().endResultViewPos).gameObject.transform;
  85. GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
  86. obj.transform.parent = FuJianParent.transform;
  87. obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
  88. obj.name = "ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text;
  89. obj.GetComponent<inspectResultList_Button>().SetText_ID(inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text);
  90. obj.GetComponent<inspectResultList_Button>().SetText_Tag(inspectList.taskList[i].GetComponent<InspectList_Button>().text_name.text);
  91. obj.GetComponent<inspectResultList_Button>().SetText_Status(inspectList.taskList[i].GetComponent<InspectList_Button>().startInspect);
  92. tagTextFuJian.text = inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks + "检查结果";
  93. }
  94. }
  95. if (inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks == peiZhi)
  96. {
  97. if (PeiZhiParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text) == null)
  98. {
  99. tagText_PeiZhi.text = inspectList.taskList[i].GetComponent<InspectList_Button>().mainSubtasks + "检查结果";
  100. startPos = ResultViewListParent_PeiZhi.Find(inspectList.taskList[i].GetComponent<InspectList_Button>().endResultViewPos).gameObject.transform;
  101. GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
  102. obj.transform.parent = PeiZhiParent.transform;
  103. obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
  104. obj.name = "ResultView" + inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text;
  105. obj.GetComponent<inspectResultList_Button>().SetText_ID(inspectList.taskList[i].GetComponent<InspectList_Button>().text_num.text);
  106. obj.GetComponent<inspectResultList_Button>().SetText_Tag(inspectList.taskList[i].GetComponent<InspectList_Button>().text_name.text);
  107. obj.GetComponent<inspectResultList_Button>().SetText_Status(inspectList.taskList[i].GetComponent<InspectList_Button>().startInspect);
  108. }
  109. }
  110. }
  111. }
  112. }