using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; public class InventoryUI : MonoBehaviour { public static InventoryUI Instance; [Header("拖拽图片")] public Image dragItem; [Header("RawImage的Texture")] public RawImage rawImage; [Header("监控的对应楼道名称")] public TextMeshProUGUI RawImageText; public RawImageButton[] rawImageButton; [Header("监控视频的显示UI")] public GameObject SXJrawUI; [Header("移动的UI组")] public MoveUI[] MoveUIzu; [Header("物资信息UI")] public GameObject MaterialObjUI; [Header("物資信息的子物品 实际物品信息参数")] public List contentUIs; [Header("物资信息按钮信息集合")] public MaterialButton[] materialButtons; [Header("不足显示的按钮")] public GameObject Button1; [Header("加载UI前的一个弹窗UI")] public GameObject LoadUI; [Header("头歌字符")] private bool isCheckResult; public Text eduderText; void Start() { Instance = this; GetRawImagebutton(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.J)) { for(var i = 0; i < MoveUIzu.Length; i++) { MoveUIzu[i].Collapse(); } } if (Input.GetKeyDown(KeyCode.L)) { for (var i = 0; i < MoveUIzu.Length; i++) { MoveUIzu[i].Release(); } } if (isCheckResult) { if (eduderText.text.Contains("Y")) { //执行无人车函数 AImove.Instance.CallAImove(); //关闭评测窗口 isCheckResult = false; LoadUI.SetActive(false); } } if (Input.GetKeyDown(KeyCode.K)) { } } public void ResetMaterial() { for(var i = 0; i < contentUIs.Count; i++) { contentUIs[i].nameui.text = ""; contentUIs[i].numberui.text =""; contentUIs[i].stateui.text= ""; } } /// /// 获取RawImageButton数组 并遍历传进去序号 加一个物资信息获取 /// public void GetRawImagebutton() { for(var i = 0; i < rawImageButton.Length; i++) { rawImageButton[i].slotIndex = i; } for(var i = 0; i < materialButtons.Length; i++) { materialButtons[i].ID = i; } } /// /// 选中UI高亮打开图片 /// /// 序号 public void UpdateCameraHightlight(int index) { foreach (var slot in materialButtons) { MoveTool.Instance.MoveScale(MaterialObjUI, 0); slot.isOpen = false; } foreach (var slot in rawImageButton) { //if (slot.slotIndex == index && slot.isOpen) //{ // slot.Hight.enabled = false; // slot.isOpen = false; // break; //} //if (slot.slotIndex == index&&slot.isOpen!=true) //{ // slot.Hight.enabled = true; // slot.isOpen = true; //} if (slot.slotIndex == index) { if (slot.isOpen) { slot.Hight.enabled = false; slot.isOpen = false; // break; } else { slot.Hight.enabled = true; slot.isOpen = true; } SXJrawUI.SetActive(slot.isOpen); RawImageText.text = slot.NmaeText.ToString(); } else { slot.isOpen = false; slot.Hight.enabled = false; } } } /// /// 物资信息的UI开启 /// /// public void UpdateCameraMaterialImager(int index) { foreach (var slot in rawImageButton) { slot.isOpen = false; slot.Hight.enabled = false; SXJrawUI.SetActive(slot.isOpen); } Button1.SetActive(false); foreach (var slot in materialButtons) { if (slot.ID == index) { if (slot.isOpen) { MoveTool.Instance.MoveScale(MaterialObjUI, 0); slot.isOpen = false; } else { slot.isOpen = true; MoveTool.Instance.MoveScale(MaterialObjUI, 1); ResetMaterial(); for(var i = 0; i < slot.dataContent.Count; i++) { contentUIs[i].nameui.text = slot.dataContent[i].name; contentUIs[i].numberui.text = slot.dataContent[i].quantity.ToString(); if (slot.dataContent[i].quantity > slot.dataContent[i].judgment) { contentUIs[i].stateui.text = "充足"; } else { contentUIs[i].stateui.text = "不足"; Button1.SetActive(true); } } } } else { slot.isOpen = false; } } } /// /// 关闭监控画面和物资信息 /// public void OFFui() { foreach (var slot in rawImageButton) { slot.isOpen = false; slot.Hight.enabled = false; SXJrawUI.SetActive(slot.isOpen); } foreach (var slot in materialButtons) { MoveTool.Instance.MoveScale(MaterialObjUI, 0); slot.isOpen = false; } } /// /// 物资详情的按钮 /// public void DetailsButton() { AImove.Instance.AIposInt = 0; isCheckResult = true; OFFui(); LoadUI.SetActive(true); } }