66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_ToolAndMaterialPanel : BasePanel
|
|
{
|
|
public void Init()
|
|
{
|
|
}
|
|
|
|
|
|
public override void ShowMe()
|
|
{
|
|
CreatItem(0); //默认打开显示工器具
|
|
}
|
|
|
|
public override void HideMe()
|
|
{
|
|
}
|
|
|
|
|
|
private void CreatItem(int type)
|
|
{
|
|
var bagData = GameManager.PacksackBagMgr.GetCurrentBagData();
|
|
|
|
foreach (var toolAndMaterialData in bagData.Values)
|
|
{
|
|
if (toolAndMaterialData.type != type)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
string iconName = GameManager.ToolAndmaterialMgr.GetIconSpriteName(toolAndMaterialData.objName);
|
|
if (iconName != null)
|
|
{
|
|
var toolAndMaterItem = GameManager.ResourcesMgr.Load<GameObject>(Const.UI_Item +
|
|
"UI_ToolAndMaterialPanel/" +
|
|
"ToolAndMeterialItem");
|
|
|
|
toolAndMaterItem.GetComponent<Image>().sprite =
|
|
GameManager.ResourcesMgr.Load<Sprite>(Const.TitleSpritePath + iconName);
|
|
toolAndMaterItem.GetComponentInChildren<Text>().text = toolAndMaterialData.count.ToString();
|
|
|
|
toolAndMaterItem.transform.parent = GetControl<ScrollRect>("itemScrollView").content;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnClick(string btnName)
|
|
{
|
|
switch (btnName)
|
|
{
|
|
case "closeBtn":
|
|
GameManager.UIMgr.HidePanel<UI_ToolAndMaterialPanel>();
|
|
break;
|
|
case "toolBtn":
|
|
CreatItem(0);
|
|
break;
|
|
case "deviceBtn":
|
|
CreatItem(1);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
} |