using System.Collections; using System.Collections.Generic; using Sirenix.OdinInspector; using TMPro; using UnityEngine; using UnityEngine.UI; public class UI_ToolOrMaterialsOrDeviceItem : BaseItem { public List itemInfoList; public Button itemCloseBtn; private ItemInfo currentItem; public void Init(List _itemInfo) { itemInfoList = _itemInfo; currentItem = itemInfoList[0]; if (GameManager.RunModelMgr.ModeType == E_ModeType.Study) { itemCloseBtn.gameObject.SetActive(false); } if (GameManager.RunModelMgr.SceneType != E_SceneType.Site) { GetControl("iconBtn").enabled = false; } GetControl("countText").text = _itemInfo.Count.ToString(); GetControl("iconBtn").sprite = Resources.Load(Const.LoadToolAndMaterialPath + currentItem.toolName); } protected override void OnClick(string btnName) { base.OnClick(btnName); switch (btnName) { case "itemCloseBtn": int counts = 0; ; if (itemInfoList.Count > 1) { counts = itemInfoList.Count - 1; } GameObject obj = Instantiate(itemInfoList[counts].objPrefab); obj.transform.position = itemInfoList[counts].selfPosInToolRoom; obj.name = itemInfoList[counts].toolName; obj.GetComponent().itemInfo = itemInfoList[counts]; GameManager.PacksackBagMgr.RemoveOneToolOrMater(itemInfoList[counts]); itemInfoList.Remove(itemInfoList[counts]); GetControl("CountText").text = itemInfoList.Count.ToString(); if (itemInfoList.Count == 0) Destroy(gameObject); break; case "iconBtn": GameManager.UIMgr.HidePanel(); GameObject currentTool = Instantiate(currentItem.objPrefab); currentTool.name = currentItem.toolName; currentTool.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 1f; break; } } }