private bool CanExecuteGestureWithOtherGesturesOrFail(EGestureActionCallbackState value) { // if we are trying to execute from a non-executing state and there are gestures already executing, // we need to make sure we are allowed to execute simultaneously if (ActiveGestues.Count != 0 && ( value == EGestureActionCallbackState.Began || value == EGestureActionCallbackState.Executing || value == EGestureActionCallbackState.Ended ) && this.State != EGestureActionCallbackState.Began && this.State != EGestureActionCallbackState.Executing) { // check all the active gestures and if any are not allowed to simultaneously // execute with this gesture, fail this gesture immediately foreach (IGestureActionCallbackBase gesture in ActiveGestues) { if (gesture != this && (!AllowSimultaneousExecutionIfPlatformSpecificViewsAreDifferent && !this.m_SimultaneousGesturesCallbackList.Contains(gesture) && !gesture.m_SimultaneousGesturesCallbackList.Contains(this) && !m_SimultaneousGesturesCallbackList.Contains(AllRefrenceGestureCallback) && !gesture.m_SimultaneousGesturesCallbackList.Contains(AllRefrenceGestureCallback))) { this.FailedGestureNow(); //FailGestureNow(); return(false); } } } return(true); }
public bool SetState(EGestureActionCallbackState state) { //Debug.Log("SetState:"+state); if (state == EGestureActionCallbackState.Failed) { //Debug.LogError("SetFailed"); this.FailedGestureNow(); return(true); } else if (this.CanExecuteGestureWithOtherGesturesOrFail(state) == false) { return(false); } else if (state == EGestureActionCallbackState.Ended && this.CheckRequiredGesturesToFail()) { this.State = EGestureActionCallbackState.EndPending; return(false); } else { if (state == EGestureActionCallbackState.Began || state == EGestureActionCallbackState.Executing) { this.State = state; ActiveGestues.Add(this); this.UpdateTouchState(state == EGestureActionCallbackState.Executing); this.StateChange(); } else if (state == EGestureActionCallbackState.Ended) { EndGesture(); // end after a one frame delay, this allows multiple gestures to properly // fail if no simulatenous execution allowed and there were multiple ending at the same frame ActiveGestues.Add(this); if (this.m_MonoScript != null) { this.m_MonoScript.StartCoroutine(this.RemoveActionDelay(this.RemoveActiveGestureCallback)); } else { Debug.LogError("No Mono"); } //RunActionAfterDelay(0.001f, RemoveFromActiveGestures); } else { this.State = state; this.StateChange(); } } return(true); }