I am not sure why this is happening, but when a user taps on a UI button on the screen, TapStart.Invoke();
is getting triggered. It should only trigger when the screen is tapped, and the tap isn't on a button.
I assumed that this would stop it: EventSystem.current.currentSelectedGameObject == null
but it doesn't seem to be doing so.
void Update() {
if (Input.touches.Length == 1) {
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved && HasStarted) {
Swipe.Invoke(StartPosition, touch.position);
IsSwiping = true;
}
if (touch.phase == TouchPhase.Ended) {
if (!IsSwiping && EventSystem.current.currentSelectedGameObject == null) {
if (GameManager.Instance.Toast.ResetReady) {
TapRestart.Invoke();
} else {
TapStart.Invoke();
}
}
IsSwiping = false;
HasStarted = false;
}
}
}