123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.EventSystems;
- public class UIManager : MonoBehaviour
- {
- private GraphicRaycaster raycaster;
- private PointerEventData eventData;
- private EventSystem eventSystem;
- public Transform selectionPoint;
- // Start is called before the first frame update
- void Start()
- {
- raycaster = GetComponent<GraphicRaycaster>();
- eventSystem = GetComponent<EventSystem>();
- eventData = new PointerEventData(eventSystem);
- eventData.position = selectionPoint.position;
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- public bool OnEnetered(GameObject button)
- {
- List<RaycastResult> results = new List<RaycastResult>();
- raycaster.Raycast(eventData, results);
- foreach(var result in results)
- {
- if(result.gameObject == button)
- {
- return true;
- }
- }
- return false;
- }
- }
|