ShowXunJian_UIItem.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Blue;
  4. using GHZLangChao;
  5. using SC.XR.Unity;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. public class ShowXunJian_UIItem : MonoBehaviour, IController
  9. {
  10. [SerializeField] private Button mNormal_Btn; //正常
  11. [SerializeField] private Button Warning_Btn; //异常
  12. [SerializeField] private GameObject NormalBG1_go;
  13. [SerializeField] private GameObject NormalBG2_go;
  14. [SerializeField] private GameObject WarningBG1_go;
  15. [SerializeField] private GameObject WarningBG2_go;
  16. [SerializeField] private GameObject NormalPanel_go;
  17. [SerializeField] private GameObject WarningPanel_go;
  18. [SerializeField] private SCInputField LabelText_Input;
  19. private void Start()
  20. {
  21. mNormal_Btn.onClick.AddListener(NormalClick);
  22. Warning_Btn.onClick.AddListener(WarningClick);
  23. }
  24. private void OnEnable()
  25. {
  26. StartCoroutine(SetCurrentUIItem());
  27. }
  28. private IEnumerator SetCurrentUIItem()
  29. {
  30. yield return new WaitForSeconds(0.01f);
  31. StartXunJian.Instance.currentUIItem = this;
  32. }
  33. private int mItemID; // 检查项目的编号 1-12
  34. private bool mNormal = true; //是否正常
  35. private string mLabel = ""; // 标签
  36. private int mInspectionId; // 巡检编号,巡检开始时返回的id
  37. public void Set()
  38. {
  39. this.GetService<IInspectionService>().Set(mItemID, mNormal, mLabel, mInspectionId);
  40. }
  41. public void InitData(int ItemID, int InspectionId, InspectionStep InspectionStep = null)
  42. {
  43. mItemID = ItemID;
  44. mInspectionId = InspectionId;
  45. if (InspectionStep != null)
  46. {
  47. if (InspectionStep.normal)
  48. NormalClick();
  49. else
  50. WarningClick();
  51. if (!string.IsNullOrWhiteSpace(InspectionStep.label))
  52. {
  53. LabelText_Input.text = InspectionStep.label;
  54. mLabel = InspectionStep.label;
  55. }
  56. }
  57. }
  58. public void SetLabel(string Label)
  59. {
  60. mLabel = Label;
  61. }
  62. private void NormalClick()
  63. {
  64. NormalBG1_go.SetActive(true);
  65. NormalBG2_go.SetActive(false);
  66. WarningBG1_go.SetActive(false);
  67. WarningBG2_go.SetActive(true);
  68. NormalPanel_go.SetActive(true);
  69. WarningPanel_go.SetActive(false);
  70. mNormal = true;
  71. }
  72. private void WarningClick()
  73. {
  74. NormalBG1_go.SetActive(false);
  75. NormalBG2_go.SetActive(true);
  76. WarningBG1_go.SetActive(true);
  77. WarningBG2_go.SetActive(false);
  78. NormalPanel_go.SetActive(false);
  79. WarningPanel_go.SetActive(true);
  80. mNormal = false;
  81. }
  82. }