using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.U2D;
using UnityEngine.UI;
///
/// This class' only purpose is to set the price of a UI element
///
[RequireComponent(typeof(Sprite))]
public class ItemIconDisplay : MonoBehaviour
{
[SerializeField]
protected SpriteAtlas iconAtlas;
private Image sprite;
private void Start()
{
sprite = GetComponent(); // Because of the meta tag, Unity will make sure this exists. No sanity checks
}
public void SetIcon(string name)
{
if(sprite == null) sprite = GetComponent(); // Just in case this gets called before Start()
sprite.sprite = iconAtlas.GetSprite(name);
}
}