init
This commit is contained in:
58
official/DisplayItemValue/ModBehaviour.cs
Normal file
58
official/DisplayItemValue/ModBehaviour.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Duckov.UI;
|
||||
using Duckov.Utilities;
|
||||
using ItemStatsSystem;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace DisplayItemValue
|
||||
{
|
||||
|
||||
public class ModBehaviour : Duckov.Modding.ModBehaviour
|
||||
{
|
||||
TextMeshProUGUI _text = null;
|
||||
TextMeshProUGUI Text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_text == null)
|
||||
{
|
||||
_text = Instantiate(GameplayDataSettings.UIStyle.TemplateTextUGUI);
|
||||
}
|
||||
return _text;
|
||||
}
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
Debug.Log("DisplayItemValue Loaded!!!");
|
||||
}
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_text != null)
|
||||
Destroy(_text);
|
||||
}
|
||||
void OnEnable()
|
||||
{
|
||||
ItemHoveringUI.onSetupItem += OnSetupItemHoveringUI;
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
ItemHoveringUI.onSetupItem -= OnSetupItemHoveringUI;
|
||||
}
|
||||
|
||||
private void OnSetupItemHoveringUI(ItemHoveringUI uiInstance, Item item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
Text.gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Text.gameObject.SetActive(true);
|
||||
Text.transform.SetParent(uiInstance.LayoutParent);
|
||||
Text.transform.localScale = Vector3.one;
|
||||
Text.text = $"${item.GetTotalRawValue() / 2}";
|
||||
Text.fontSize = 20f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user