public override void Reset() { TargetState = Gestures.Gesture.GestureState.Recognized; GameObject = null; Gesture = null; Component = null; SendEvent = null; }
/// <summary> /// Returns cached instance of EventArgs. /// This cached EventArgs is reused throughout the library not to alocate new ones on every call. /// </summary> /// <param name="state"> Current gesture state. </param> /// <param name="previousState"> Previous gesture state. </param> /// <returns>Cached EventArgs object.</returns> public static GestureStateChangeEventArgs GetCachedEventArgs(Gesture.GestureState state, Gesture.GestureState previousState) { if (instance == null) { instance = new GestureStateChangeEventArgs(); } instance.State = state; instance.PreviousState = previousState; return(instance); }
// ---------------------------------------------------------------- // Update is called once per frame void LateUpdate() { if (this.enabled && !this.isActiveAndEnabled) { ResetState(); return; } state = gesture.State; if (neighbourGesture != null) { neighbourState = neighbourGesture.State; } if (state == Gesture.GestureState.Changed) { isUserLearnt = true; gestureHints.ForEach(go => go.SetActive(false && go.activeSelf)); RectSizeCheck(); } }
internal Gesture.GestureState INTERNAL_GestureChangeState(Gesture gesture, Gesture.GestureState state) { bool recognized = false; switch (state) { case Gesture.GestureState.Idle: case Gesture.GestureState.Possible: break; case Gesture.GestureState.Began: switch (gesture.State) { case Gesture.GestureState.Idle: case Gesture.GestureState.Possible: break; default: print(string.Format("Gesture {0} erroneously tried to enter state {1} from state {2}", new object[] { gesture, state, gesture.State })); break; } recognized = recognizeGestureIfNotPrevented(gesture); if (!recognized) { if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } return(Gesture.GestureState.Failed); } break; case Gesture.GestureState.Changed: switch (gesture.State) { case Gesture.GestureState.Began: case Gesture.GestureState.Changed: break; default: print(string.Format("Gesture {0} erroneously tried to enter state {1} from state {2}", new object[] { gesture, state, gesture.State })); break; } break; case Gesture.GestureState.Failed: if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } break; case Gesture.GestureState.Recognized: // Ended if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } switch (gesture.State) { case Gesture.GestureState.Idle: case Gesture.GestureState.Possible: recognized = recognizeGestureIfNotPrevented(gesture); if (!recognized) { return(Gesture.GestureState.Failed); } break; case Gesture.GestureState.Began: case Gesture.GestureState.Changed: break; default: print(string.Format("Gesture {0} erroneously tried to enter state {1} from state {2}", new object[] { gesture, state, gesture.State })); break; } break; case Gesture.GestureState.Cancelled: if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } break; } return(state); }
/// <summary> /// Initializes a new instance of the <see cref="GestureStateChangeEventArgs"/> class. /// </summary> /// <param name="state"> Current gesture state. </param> /// <param name="previousState"> Previous gesture state. </param> public GestureStateChangeEventArgs(Gesture.GestureState state, Gesture.GestureState previousState) { State = state; PreviousState = previousState; }
internal Gesture.GestureState GestureChangeState(Gesture gesture, Gesture.GestureState state) { switch (state) { case Gesture.GestureState.Possible: break; case Gesture.GestureState.Began: switch (gesture.State) { case Gesture.GestureState.Possible: break; default: print(String.Format("Gesture {0} erroneously tried to enter state {1} from state {2}", gesture, state, gesture.State)); break; } if (gestureCanRecognize(gesture)) { recognizeGesture(gesture); } else { if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } return(Gesture.GestureState.Failed); } break; case Gesture.GestureState.Changed: switch (gesture.State) { case Gesture.GestureState.Began: case Gesture.GestureState.Changed: break; default: print(String.Format("Gesture {0} erroneously tried to enter state {1} from state {2}", gesture, state, gesture.State)); break; } break; case Gesture.GestureState.Failed: if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } break; case Gesture.GestureState.Recognized: // Ended if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } switch (gesture.State) { case Gesture.GestureState.Possible: if (gestureCanRecognize(gesture)) { recognizeGesture(gesture); } else { return(Gesture.GestureState.Failed); } break; case Gesture.GestureState.Began: case Gesture.GestureState.Changed: break; default: print(String.Format("Gesture {0} erroneously tried to enter state {1} from state {2}", gesture, state, gesture.State)); break; } break; case Gesture.GestureState.Cancelled: if (!gesturesToReset.Contains(gesture)) { gesturesToReset.Add(gesture); } break; } return(state); }