YanCheng_Metrology/Assets/Scripts/Project/UI/UI_Item/UI_ToolOrMaterialsOrDeviceI...

48 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
public class UI_ToolOrMaterialsOrDeviceItem : BaseItem
{
public List<ItemInfo> itemInfo;
public void Init(List<ItemInfo> _itemInfo)
{
GetControl<TextMeshProUGUI>("CountText").text = _itemInfo.Count.ToString();
itemInfo = _itemInfo;
}
protected override void OnClick(string btnName)
{
base.OnClick(btnName);
switch (btnName)
{
case "ItemCloseBtn":
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
{
int counts = 0; ;
if (itemInfo.Count > 1)
{
counts = itemInfo.Count - 1;
}
GameObject obj = Instantiate(itemInfo[counts].objPrefab);
obj.transform.position = itemInfo[counts].selfPosInToolRoom;
obj.name = itemInfo[counts].toolName;
obj.GetComponent<Tool_SelectComponent>().itemInfo = itemInfo[counts];
GameManager.PacksackBagMgr.RemoveOneToolOrMater(itemInfo[counts]);
itemInfo.Remove(itemInfo[counts]);
GetControl<TextMeshProUGUI>("CountText").text = itemInfo.Count.ToString();
if (itemInfo.Count == 0)
Destroy(gameObject);
}
break;
case "UI_ToolOrMaterialsOrDeviceItem":
Debug.Log("ICon");
break;
}
}
}