Skip to content

Instantly share code, notes, and snippets.

View jacobfdunbar's full-sized avatar

Jacob Dunbar jacobfdunbar

View GitHub Profile
@jacobfdunbar
jacobfdunbar / ExampleNonUIMonoBehaviour.cs
Created January 26, 2023 16:47 — forked from NickMercer/ExampleNonUIMonoBehaviour.cs
UIToolkitRaycastChecker is a script for Unity UIElements to replicate the EventSystem.current.IsPointerOverGameObject() functionality for UI Elements.
using UnityEngine;
public class ExampleNonUIMonoBehaviour : MonoBehaviour
{
private void Start()
{
//Example of how to check for a position. This is the equivalent of EventSystem.current.IsPointerOverGameObject() except for UI Elements.
if (UIToolkitRaycastChecker.IsPointerOverUI())
{
//I'm under a part of the UI that's set to block raycasts! Don't try to raycast or something.