private void HandleLongTap(TouchInfo touchInfo) { if (GestureType != GestureType.LongTap) { return; //check that this is the gesture type this listener is listening for } if (!HasValidTarget(touchInfo)) { return; //if this is not a global listener -> check that is a valid gameObject and the correct touchInfo target } if (DebugComponent) { DDebug.Log(string.Format("OnLongTap on {0}: {1}", gameObject.name, touchInfo), this); } TriggerListener(touchInfo); }
private void HandleSwipe(TouchInfo touchInfo) { if (GestureType != GestureType.Swipe) { return; //check that this is the gesture type this listener is listening for } if (!HasValidTarget(touchInfo)) { return; //if this is not a global listener -> check that is a valid gameObject and the correct touchInfo target } if (touchInfo.Direction != SwipeDirection) { return; //check that the swipe happened in the direction this listener is listening for } if (DebugComponent) { DDebug.Log(string.Format("OnSwipe on {0}: {1}", gameObject.name, touchInfo), this); } TriggerListener(touchInfo); }
/// <summary> Returns TRUE if this is a global listener or if the touch info happened over the target game object </summary> private bool HasValidTarget(TouchInfo touchInfo) { return(GlobalListener || TargetGameObject != null && touchInfo.GameObject == TargetGameObject); }