projectEli/Assets/Inventory System/Scripts/UI/ChangeSlotTitle.cs
2023-01-15 03:39:47 -08:00

42 lines
924 B
C#

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;
}
}