This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
project-undercover/Project Undercover/Assets/Scripts/UI/CanvasClickCheck.cs

36 lines
943 B
C#
Raw Normal View History

2017-11-30 13:42:51 -06:00
using UnityEngine;
using UnityEngine.EventSystems; //required for Event data
public class CanvasClickCheck : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
GameObject currentHover;
static CanvasClickCheck Singleton;
void Start()
{
if (Singleton != null)
Debug.LogError("Should only be one Canvas Click Check");
Singleton = this;
}
public void OnPointerEnter(PointerEventData eventData)
{
if (eventData.pointerCurrentRaycast.gameObject != null)
{
Debug.Log("Mouse Over: " + eventData.pointerCurrentRaycast.gameObject.name);
currentHover = eventData.pointerCurrentRaycast.gameObject;
}
}
public void OnPointerExit(PointerEventData eventData)
{
currentHover = null;
}
void Update()
{
if (currentHover)
Debug.Log(currentHover.name + " @ " + Input.mousePosition);
}
}