title: Click and Drag a gameobject in a Overlay Canvas in Unity
body: <p>I have a Canvas setup and it is in Screen Space - Overlay and I almost have what I am looking for but the results are just a little bit off.  By a little bit off I mean when I click and hold to drag something from my inventory it isn't exactly where the mouse is but it is close.  Now the dragging doesn't work but when I am done dragging my GameObject returns to its respective place correctly.</p>
  
  <p>My Code : </p>
  
  <pre><code>void Awake(){
      rectTrans = GetComponent&lt;RectTransform&gt; ();
  }
  
  void Start(){
      localRectTrans = rectTrans.localPosition;
  }
  
  public void OnPointerUp(PointerEventData data){
      // IF we are dragging an item
      if(itemBeingDragged != null){
          itemBeingDragged = null;
          // return this gameobject to its original location.
          rectTrans.localPosition = localRectTrans;
      }
  }
  
  public void OnBeginDrag(PointerEventData data){
      // IF we have an item to drag.
      if(isItem){
          // Set the itemBeingDragged to this gameobject.
          itemBeingDragged = gameObject;
          // Get the starting mouse location for dragging.
          startMousePos = Input.mousePosition;
      }
  }
  
  public void OnDrag(PointerEventData data){
      // IF we have an item to drag in this inventory slot.
      if(isItem){
          // Get the location of the mouse.
          Vector2 curMousePosition = Input.mousePosition;
          // Get the difference in position from when the mouse was first clicked to where it is currently being dragged.
          Vector2 diffInPos = curMousePosition - startMousePos;
          // The current position based on the difference in position with the mouse and the local position of this inventory slot.
          Vector2 curPos = localRectTrans + diffInPos;
          transform.localPosition = curPos;
      }
  }
  </code></pre>
  
  <p>How can I get this to actually be exactly where my mouse cursor is?  I feel I am so close but just keep drawing a blank.</p>