using System.Collections; using TMPro; using Blue; using GHZLangChao; using SC.XR.Unity; using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; 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; [SerializeField] private List XunJianUIItemTexture_List; 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; PlayerPrefs.SetInt("ShowXunJianStep", mItemID); } private int mItemID = 1; // 检查项目的编号 1-12 private bool mNormal = true; //是否正常 private string mOutliers = ""; // 标签 private int mInspectionId; // 巡检编号,巡检开始时返回的id public void Set() { this.GetService().Set(mItemID, mNormal, mOutliers, mInspectionId, new int[3] { 1, 2, 3 }); foreach (var ByteClass in byteDic) { //Debug.LogError($"是否上传:{ByteClass.Value.upload}"); if (ByteClass.Value.upload) { byteDic[ByteClass.Key].upload = false; LangChaoMinIo.Instance.saveFile(ByteClass.Value.bytes, this.GetService().InspectionInfo.id, mItemID.ToString(), ByteClass.Key, msg => { Debug.LogError("Set:" + msg); }); } } } private Dictionary byteDic = new Dictionary(); public void ChangeSprite(int id, Texture2D Texture2D) { if (byteDic.ContainsKey(id)) byteDic[id] = new ByteClass() { upload = true, bytes = Texture2D.EncodeToPNG() }; else byteDic.Add(id, new ByteClass() { upload = true, bytes = Texture2D.EncodeToPNG() }); } 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; } for (int i = 0; i < 3; i++) { XunJianUIItemTexture_List[i].GetSprite(byteDic, mItemID, i); } } } 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().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