32 lines
815 B
C#
32 lines
815 B
C#
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class InventoryScreenInvoker : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
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;
|
|
}
|
|
|
|
var inventory = GetComponent<IInventoryHolder>();
|
|
if (inventory == null)
|
|
{
|
|
Debug.Log("Cannot show inventory screen on an object without an inventory");
|
|
return;
|
|
}
|
|
|
|
inventoryScreen.Display(inventory);
|
|
}
|
|
}
|