MonsterShop/Assets/Scripts/UI/InventoryScreenInvoker.cs

28 lines
708 B
C#

using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UIElements;
public class InventoryScreenInvoker : MonoBehaviour, IPointerClickHandler
{
public InventoryHolder SourceInventory;
public InventoryHolder TargetInventory;
public void OnPointerClick(PointerEventData eventData)
{
Show();
}
private void Show()
{
var inventoryScreen = FindObjectsByType<InventoryScreen>(FindObjectsSortMode.None).First();
if (inventoryScreen == null)
{
Debug.Log("No inventory screen defined on current scene");
return;
}
inventoryScreen.Display(SourceInventory, TargetInventory);
}
}