Button Focus Prevents Touch Raycast (Android C#)

I am working on Android and have the following touch-driven interactions in Update:

void Update()
    {
        if (Input.touchCount == 1)
        {
            thisTouch = Input.GetTouch(0);

            if (thisTouch.phase == TouchPhase.Moved)
            {
                if (Mathf.Abs(thisTouch.deltaPosition.y) > 16.0f || Mathf.Abs(thisTouch.deltaPosition.x) > 16.0f)
                {
                    hasMovedThisTouch = true;
                }
                if (hasMovedThisTouch)
                {
                    DoRotation(thisTouch.deltaPosition);
                }
            }
            else if (thisTouch.phase == TouchPhase.Ended)
            {
                if (!hasMovedThisTouch)
                {
                    DoClick();
                }
                hasMovedThisTouch = false;
            }
        }
        else if (Input.touchCount == 2)
        {
            DoZoom(Input.GetTouch(0), Input.GetTouch(1));
            hasMovedThisTouch = true;
            if (Input.GetTouch(0).phase == TouchPhase.Ended && Input.GetTouch(1).phase == TouchPhase.Ended)
            {
                hasMovedThisTouch = false;
            }
        }
        transform.LookAt(target);
    }

Which is basically: If one finger is touching and not moving, DoClick. If one finger is touching and moving, DoRotate. If two fingers are touching, DoZoom.

I also have a few buttons on my overlay canvas that affect objects in the scene. This causes a problem.

When I click a button, the next raycast is blocked. I believe that it is because an item in the GUI still has focus. I attempt to solve this by putting GUI.FocusControl(null); at the end of my Update, but this has no effect.

How do I keep my touch interactions prepared to raycast after a button has been pressed?

This problem was solved by pulling
EventSystem.current.IsPointerOverGameObject();
out of DoClick().

DoClick() must be called from TouchPhase.Ended, but IsPointerOverGameObject() must be called from TouchPhase.Began.

I just had to store an “isClickingButton” bool in my active touch so it could be accessed in both phases.

Also, IsPointerOverGameObject required (thisTouch.fingerID); to work properly.