Search Unity

OnDrag() stops being called during fast dragging movement

Discussion in 'UGUI & TextMesh Pro' started by MarkOfVarberg, Sep 2, 2014.

  1. MarkOfVarberg

    MarkOfVarberg

    Joined:
    Sep 5, 2013
    Posts:
    11
    I have the following attached to a character with BoxCollider2D and Rigidbody2D components attached:

    Code (CSharp):
    1.   public void OnDrag (PointerEventData data) {
    2.     gameObject.rigidbody2D.isKinematic = true;
    3.     float x = data.worldPosition.x;
    4.     float y = data.worldPosition.y;
    5.     transform.position = new Vector3 (x + offset.x, y + offset.y, 0f);
    6.   }
    7.  
    8.   public void OnDrop (PointerEventData data) {
    9.     gameObject.rigidbody2D.isKinematic = false;
    10.   }
    11.  
    If I drag too fast then it seems that the pointer is outside the collider region and the OnDrag handler is no longer called. Moving the pointer back inside the collider region allows the events to resume.

    Is this a bug or should I be handling this situation somehow?
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Looking at the code I can't see how this would be the case, we just use the delta of the screen space cursor position. If you could log a bug we can look at this closer.