You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
791 B
29 lines
791 B
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.U2D;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// This class' only purpose is to set the price of a UI element
|
|
/// </summary>
|
|
[RequireComponent(typeof(Sprite))]
|
|
public class ItemIconDisplay : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
protected SpriteAtlas iconAtlas;
|
|
private Image sprite;
|
|
private void Start()
|
|
{
|
|
sprite = GetComponent<Image>(); // Because of the meta tag, Unity will make sure this exists. No sanity checks
|
|
}
|
|
|
|
public void SetIcon(string name)
|
|
{
|
|
if(sprite == null) sprite = GetComponent<Image>(); // Just in case this gets called before Start()
|
|
sprite.sprite = iconAtlas.GetSprite(name);
|
|
}
|
|
}
|
|
|