📜  unity 知道鼠标何时在 ui 上 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:16.209000             🧑  作者: Mango

代码示例1
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;


public static bool IsPointerOverUIElement()
    {
        var eventData = new PointerEventData(EventSystem.current);
        eventData.position = Input.mousePosition;
        var results = new List();
        EventSystem.current.RaycastAll(eventData, results);
        return results.Where(r => r.gameObject.layer == 5).Count() > 0;
    }