void LateUpdate()
{
Debug.Log("EventSystem.current.IsPointerOverGameObject()=" +
EventSystem.current.IsPointerOverGameObject());
if (!EventSystem.current.IsPointerOverGameObject())
{
}
//if (getCon(Input.mousePosition) <= 0)
// {
// ControlCamera();
// }
}
private EventSystem es;
public GraphicRaycaster gra;//需要检测的 UICanvas
/// <summary>
/// 返回 检测到的UI 个数
/// </summary>
/// <param name="vector2">鼠标位置:Input.mousePosition</param>
/// <returns></returns>
private int getCon(Vector2 vector2)
{
PointerEventData pointerEventData = new PointerEventData(es);
pointerEventData.position = vector2;
List<RaycastResult> result = new List<RaycastResult>();
gra.Raycast(pointerEventData, result);
return result.Count;
}
Unity 检测是否在UI上的方法
猜你喜欢
转载自blog.csdn.net/qq_37524903/article/details/130215288
今日推荐
周排行