unity 判断是否点击在UI上

原文链接:UGUI -(unity3d 5)判断是否点击在UI 上 Bug,IsPointerOverGameObject()在移动输入模式检测失败

自己又封装的代码:

		public static bool IsPointerOverUI(Vector3 point)
		{
			PointerEventData eventData = new PointerEventData(UnityEngine.EventSystems.EventSystem.current);
			eventData.pressPosition = point;
			eventData.position = point;

			List<RaycastResult> list = new List<RaycastResult>();
			UnityEngine.EventSystems.EventSystem.current.RaycastAll(eventData, list);
			return list.Count > 0;
		}

猜你喜欢

转载自blog.csdn.net/qq302756113/article/details/85050264
今日推荐