Files
MedievalShopkeeper/Assets/Scripts/ShelfBuyButton.cs

31 lines
791 B
C#
Raw Normal View History

using UnityEngine;
using UnityEngine.UI;
namespace MedievalShopkeeper
{
[RequireComponent(typeof(Button))]
public class ShelfBuyButton : MonoBehaviour
{
[Tooltip("The shelf data to build when this button is clicked.")]
public PlaceableData shelfData;
private void Start()
{
Button btn = GetComponent<Button>();
btn.onClick.AddListener(OnClick);
}
private void OnClick()
{
if (shelfData != null && BuildManager.Instance != null)
{
// Close UI before building
if (UIManager.Instance != null) UIManager.Instance.CloseAllMenus();
BuildManager.Instance.StartBuilding(shelfData);
}
}
}
}