using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class UIManager : MonoBehaviour { private GraphicRaycaster raycaster; private PointerEventData pData; private EventSystem eventSystem; public Transform selectionPoint; public static UIManager instance; public static UIManager Instance { get { if (instance == null) { instance = FindAnyObjectByType(); } return instance; } } // Start is called before the first frame update void Start() { raycaster = GetComponent(); eventSystem = GetComponent(); pData = new PointerEventData(eventSystem); pData.position = selectionPoint.position; } public bool OnEntered(GameObject button) { List results = new List(); raycaster.Raycast(pData, results); foreach (var result in results) { if (result.gameObject == button) return true; } return false; } }