Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
if (!EventSystem.current.IsPointerOverGameObject())
If you use IsPointerOverGameObject() without a parameter, it points to the "left mouse button" (pointerId = -1); therefore when you use IsPointerOverGameObject for touch, you should consider passing a pointerId to it.
if (!EventSystem.current.IsPointerOverGameObject()) WoodFarmPanel.SetActive(true);
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) {
if (EventSystem.current.IsPointerOverGameObject()) {}
public void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject() || EventSystem.current.currentSelectedGameObject != null) { } else { FoodFarmPanel.SetActive(true); } }
FoodFarmPanel.SetActive(true);
private static bool IsPointerOverUIObject() { PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current); #if !ANDROID eventDataCurrentPosition.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y,Input.mousePosition.z); #else eventDataCurrentPosition.position = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y); #endif List<RaycastResult> results = new List<RaycastResult>(); EventSystem.current.RaycastAll(eventDataCurrentPosition, results); return results.Count > 0; }