123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System.Collections;
- using TMPro;
- 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;
- [SerializeField] private GameObject mErrorBtn_go;
- public Image Screenshot_0_Image;
- public Image Screenshot_1_Image;
- public Image Screenshot_2_Image;
- private void Start()
- {
- mNormal_Btn.onClick.AddListener(NormalClick);
- Warning_Btn.onClick.AddListener(WarningClick);
- LabelText_Input.onValueChanged.AddListener(NewStr => mOutliers = NewStr);
- }
- private void OnEnable()
- {
- StartCoroutine(SetCurrentUIItem());
- }
- private IEnumerator SetCurrentUIItem()
- {
- yield return new WaitForSeconds(0.01f);
- StartXunJian.Instance.currentUIItem = this;
- }
- private int mItemID; // 检查项目的编号 1-12
- private bool mNormal = true; //是否正常
- private string mOutliers = ""; // 标签
- private int mInspectionId; // 巡检编号,巡检开始时返回的id
- public void Set()
- {
- this.GetService<IInspectionService>().Set(mItemID, mNormal, mOutliers, mInspectionId, new string[3] { "1", "2", "3" });
- }
- 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.outliers))
- {
- LabelText_Input.text = InspectionStep.outliers;
- mOutliers = InspectionStep.outliers;
- }
- foreach (var imageIndex in InspectionStep.images)
- {
- LangChaoMinIo.Instance.getFile(this.GetService<IInspectionService>().InspectionInfo.id , mItemID.ToString(), imageIndex, Texture2D =>
- {
- });
- }
- }
- }
- private float mErrorBtn_go_offset = 319;
- public void SetlabelBtnCount(string[] labelList)
- {
- foreach (string label in labelList)
- {
- GameObject go = Instantiate(mErrorBtn_go, mErrorBtn_go.transform.parent);
- go.GetComponentInChildren<TMP_Text>().text = label;
- go.name = label;
- Vector3 v3 = mErrorBtn_go.transform.localPosition;
- v3.x += mErrorBtn_go_offset;
- go.transform.localPosition = v3;
- go.SetActive(true);
- go.GetComponent<Button>().onClick.AddListener(() =>
- {
- LabelText_Input.text += go.name;
- mOutliers = LabelText_Input.text;
- });
- }
- }
- public void SetLabel(string Label)
- {
- mOutliers = 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;
- }
- }
|