static void CheckGestures() { UIGestureRecognizer highestGesture = null; //Update the active gesture first, to see if it is still active UIGestureRecognizer lastActiveGesture = activeGesture; if (activeGesture != null) { activeGesture.Sample(); if (activeGesture.state == GestureState.Possible || activeGesture.state == GestureState.Failed || activeGesture.state == GestureState.Canceled || activeGesture.state == GestureState.None) { activeGesture = null; } } for (int i = 0; i < recognizers.Count; i++) { //since we sampled the activeGesture already, and it may be null, don't sample it again. if (lastActiveGesture != recognizers[i]) { //If there isn't already an active gesture, we check all, otherwise, we only update gestures that allow simultaneous recognition, however they won't replace the active gesture if (activeGesture == null) { recognizers[i].Sample(); GestureState sampleState = recognizers[i].state; if (highestGesture == null || recognizers[i].uiTransformNode.WorldDepth > highestGesture.uiTransformNode.WorldDepth) { if (sampleState == GestureState.Began || sampleState == GestureState.Changed || sampleState == GestureState.Recognized) { highestGesture = recognizers[i]; } } } else if (recognizers[i].AllowSimultaneousRecognition) { recognizers[i].Sample(); } } } //Assign a new active gesture if (highestGesture != null) { activeGesture = highestGesture; } for (int i = 0; i < recognizers.Count; i++) { if (activeGesture != null && activeGesture != recognizers[i] && !recognizers[i].AllowSimultaneousRecognition) { // Debug.Log(activeGesture); recognizers[i].OverrideGesture(); } if (recognizers[i].sendStateChangeMessage) { recognizers[i].SignalState(); } } }