Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public static class UIHelper
- {
- private static List<RaycastResult> results = new List<RaycastResult>();
- public static List<RaycastResult> RaycastMouse()
- {
- PointerEventData pointerData = new PointerEventData(EventSystem.current)
- {
- pointerId = -1,
- };
- pointerData.position = Input.mousePosition;
- results.Clear();
- EventSystem.current.RaycastAll(pointerData, results);
- return results;
- }
- public static bool IsOnUi()
- {
- var r = RaycastMouse();
- foreach (var result in r)
- {
- if (result.isValid)
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment