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(FindObjectsSortMode.None).First(); if (inventoryScreen == null) { Debug.Log("No inventory screen defined on current scene"); return; } var inventory = GetComponent(); if (inventory == null) { Debug.Log("Cannot show inventory screen on an object without an inventory"); return; } inventoryScreen.Display(inventory); } }