123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System.Collections;
- using System.Collections.Generic;
- using Blue;
- using GHZLangChao;
- using SC.XR.Unity;
- using UnityEngine;
- using UnityEngine.UI;
- public class ShowXunJian_UIItem : MonoBehaviour, IController
- {
- [SerializeField] private Button mNormal_Btn;
- [SerializeField] private Button Warning_Btn;
- [SerializeField] private GameObject NormalBG1_go;
- [SerializeField] private GameObject NormalBG2_go;
- [SerializeField] private GameObject WarningBG1_go;
- [SerializeField] private GameObject WarningBG2_go;
- [SerializeField] private GameObject NormalPanel_go;
- [SerializeField] private GameObject WarningPanel_go;
- [SerializeField] private SCInputField LabelText_Input;
- private void Start()
- {
- mNormal_Btn.onClick.AddListener(NormalClick);
- Warning_Btn.onClick.AddListener(WarningClick);
- LabelText_Input.onValueChanged.AddListener(NewStr => mLabel = NewStr);
- }
- private void OnEnable()
- {
- StartCoroutine(SetCurrentUIItem());
- }
- private IEnumerator SetCurrentUIItem()
- {
- yield return new WaitForSeconds(0.01f);
- StartXunJian.Instance.currentUIItem = this;
- }
- private int mItemID;
- private bool mNormal = true;
- private string mLabel = "";
- private int mInspectionId;
- public void Set()
- {
- this.GetService<IInspectionService>().Set(mItemID, mNormal, mLabel, mInspectionId);
- }
- public void InitData(int ItemID, int InspectionId, InspectionStep InspectionStep = null)
- {
- mItemID = ItemID;
- mInspectionId = InspectionId;
- if (InspectionStep != null)
- {
- if (InspectionStep.normal)
- NormalClick();
- else
- WarningClick();
- if (!string.IsNullOrWhiteSpace(InspectionStep.label))
- {
- LabelText_Input.text = InspectionStep.label;
- mLabel = InspectionStep.label;
- }
- }
- }
- public void SetLabel(string Label)
- {
- mLabel = Label;
- }
- private void NormalClick()
- {
- NormalBG1_go.SetActive(true);
- NormalBG2_go.SetActive(false);
- WarningBG1_go.SetActive(false);
- WarningBG2_go.SetActive(true);
- NormalPanel_go.SetActive(true);
- WarningPanel_go.SetActive(false);
- mNormal = true;
- }
- private void WarningClick()
- {
- NormalBG1_go.SetActive(false);
- NormalBG2_go.SetActive(true);
- WarningBG1_go.SetActive(true);
- WarningBG2_go.SetActive(false);
- NormalPanel_go.SetActive(false);
- WarningPanel_go.SetActive(true);
- mNormal = false;
- }
- }
|