我在脚本中使用 EventSystem.current.IsPointerOverGameObject,并且 Unity 返回 True,即使我发誓指针下方没有 UI/EventSystem 对象。
如何找到有关 EventSystem 正在检测的对象的信息?
In your update()
:
if(Input.GetMouseButton(0))
{
PointerEventData pointer = new PointerEventData(EventSystem.current);
pointer.position = Input.mousePosition;
List<RaycastResult> raycastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointer, raycastResults);
if(raycastResults.Count > 0)
{
foreach(var go in raycastResults)
{
Debug.Log(go.gameObject.name,go.gameObject);
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)