52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
public class ItemUIListBox : MonoBehaviour
|
|
{
|
|
[SerializeField] private TextMeshProUGUI txtItem;
|
|
[SerializeField] private Image icon;
|
|
|
|
public string[] strDataName = new string[20];
|
|
public string[] strDataPtrName = new string[20];
|
|
public string[] strData64Name = new string[20];
|
|
public ulong[] uiData64 = new ulong[20];
|
|
public uint[] dwData = new uint[20];
|
|
public object[] pvData = new object[20];
|
|
public int indexItem;
|
|
public string strText;
|
|
|
|
Button btnItem = null;
|
|
public void OnEnable()
|
|
{
|
|
if(btnItem == null)
|
|
{
|
|
btnItem = GetComponent<Button>();
|
|
}
|
|
}
|
|
|
|
public void SetText(string txt)
|
|
{
|
|
strText = txt;
|
|
txtItem.text = txt;
|
|
}
|
|
|
|
public void SetIcon(Sprite sprite)
|
|
{
|
|
if (icon == null) return;
|
|
icon.sprite = sprite;
|
|
icon.enabled = sprite != null;
|
|
}
|
|
|
|
public void SetActOnClickBtn(Action<int> onClick, int index)
|
|
{
|
|
btnItem.onClick.RemoveAllListeners();
|
|
indexItem = index;
|
|
btnItem.onClick.AddListener(()=> { onClick?.Invoke(indexItem); });
|
|
}
|
|
}
|
|
}
|