카테고리 없음

IsPointerOverGameObject

소나무꼴 2021. 5. 12. 17:29

EventSystem.current.IsPointerOverGameObject

 

 

public class TouchExample : MonoBehaviour
{
    void Update()
    {
        // Check if there is a touch
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
        {
            // Check if finger is over a UI element
            if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
            {
                Debug.Log("Touched the UI");
            }
        }
    }
}