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 list = new List();
			UnityEngine.EventSystems.EventSystem.current.RaycastAll(eventData, list);
			return list.Count > 0;
		}

 

你可能感兴趣的:(unity 判断是否点击在UI上)