projectEli/Assets/Inventory System/Scripts/UI/ChangeSlotTitle.cs

42 lines
924 B
C#
Raw Normal View History

2023-01-15 11:39:47 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using System;
namespace SimpleInventorySystem {
public class ChangeSlotTitle : MonoBehaviour
{
public SlotTitlePair[] SlotTitlePairs;
public TextMeshProUGUI text;
private string oldText;
public void Start()
{
oldText = text.text;
}
public void ChangeTitle(ItemTags itemTag)
{
for(int i = 0; i < SlotTitlePairs.Length; i++)
{
if(SlotTitlePairs[i].itemTag == itemTag)
{
text.text = SlotTitlePairs[i].title;
}
}
}
public void ResetTitle()
{
text.text = oldText;
}
}
[Serializable]
public class SlotTitlePair
{
public ItemTags itemTag;
public string title;
}
}