Hello! I am using a script to rotate the camera around with touches.
I want to block the movement when I touch a button, slider or any other UI element.
I am using this code:
void FixedUpdate()
{
if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId))
{
if (Input.touchCount > 0)
{
touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
rotationY = Mathf.Clamp(rotationY, -minY, minZ);
transform.rotation = originalRotation * Quaternion.Euler(0, rotationY, 0);
}
}
}
}
What is wrong?
The camera can no longer be moved even if I don’t touch any UI element.
If I remove if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId))
the camera can be moved again.
How to block the movement just if I touch the UI elements?
Thank you!