56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public partial class HUD_BaseIcon : UIElementBase, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
public Image icon;
|
|
public List<TMP_Text> textList;
|
|
public TMP_Text iconText => textList[0];
|
|
|
|
protected InformationBox infoBox;
|
|
|
|
public virtual void UpdateIcon()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public partial class HUD_BaseIcon
|
|
{
|
|
public void SetText(int textIndex, Func<string> getText)
|
|
{
|
|
if (textIndex < 0 || textIndex >= textList.Count)
|
|
{
|
|
Debug.LogWarning($"Text index {textIndex} is out of range.");
|
|
return;
|
|
}
|
|
|
|
TMP_Text text = textList[textIndex];
|
|
if (getText != null)
|
|
{
|
|
text.gameObject.SetActive(true);
|
|
text.text = getText();
|
|
}
|
|
else
|
|
{
|
|
text.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
} |