Skip to content

Instantly share code, notes, and snippets.

@NickMercer
NickMercer / ExampleNonUIMonoBehaviour.cs
Created July 14, 2022 00:55
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.
@NickMercer
NickMercer / DemoAirHorn
Last active October 20, 2021 19:10
Pattern for reusable Unity Components using interfaces.
public class DemoAirHorn : MonoBehaviour, IThingBehaviour
{
public void DoAThing()
{
Debug.Log("EEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
}
public int ReturnAThing(int number)
{
return number + 1;