Skip to content
Permalink
Browse files

Fixed a rare null pointer exception in LongPressGesture.

  • Loading branch information...
valyard committed Jul 23, 2017
1 parent 4503022 commit 60aabf875d71231aa6ea647a4558501c6467782e
Showing with 6 additions and 9 deletions.
  1. +6 −9 Source/Assets/TouchScript/Scripts/Gestures/LongPressGesture.cs
@@ -42,7 +42,7 @@ public class LongPressGesture : Gesture
// Needed to overcome iOS AOT limitations
private EventHandler<EventArgs> longPressedInvoker;

public GestureEvent OnLongPress = new GestureEvent();
public GestureEvent OnLongPress = new GestureEvent();

#endregion

@@ -149,7 +149,7 @@ protected override void onRecognized()
base.onRecognized();
if (longPressedInvoker != null) longPressedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
if (UseSendMessage && SendMessageTarget != null) SendMessageTarget.SendMessage(LONG_PRESS_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
if (UseUnityEvents) OnLongPress.Invoke(this);
if (UseUnityEvents) OnLongPress.Invoke(this);
}

/// <inheritdoc />
@@ -173,14 +173,11 @@ private IEnumerator wait()

if (State == GestureState.Possible)
{
if (GetScreenPositionHitData().Target.IsChildOf(cachedTransform))
{
setState(GestureState.Recognized);
}
else
{
var data = GetScreenPositionHitData();
if (data.Target == null || !data.Target.IsChildOf(cachedTransform))
setState(GestureState.Failed);
}
else
setState(GestureState.Recognized);
}
}

0 comments on commit 60aabf8

Please sign in to comment.
You can’t perform that action at this time.