title: Moving UI with Screen Space - Camera (Unity)
body: <p>I want to move an image UI when Canvas is set on Screen Space - Camera</p>
  
  <p>However, nothing seems to work. I've tried the following things:</p>
  
  <pre><code>    public void OnDrag(PointerEventData eventData)
  {
  
          Vector3 screenPoint = Input.mousePosition;
          screenPoint.z = 0.13f; //distance of the plane from the camera
          icon.transform.position = Camera.main.ScreenToWorldPoint(screenPoint);
      }
  </code></pre>
  
  <p>Makes the image move out of the screen instantly. </p>
  
  <pre><code> public GameObject Target;
  private EventTrigger _eventTrigger;
  void Start ()
  {
      _eventTrigger = GetComponent&lt;EventTrigger&gt;();
      _eventTrigger.AddEventTrigger(OnDrag, EventTriggerType.Drag);
  }
  
  void OnDrag(BaseEventData data)
  {
      PointerEventData ped = (PointerEventData) data;
      Target.transform.Translate(ped.delta);
  }
  </code></pre>
  
  <p>same story, image dissapires and moves out of the screen.</p>
  
  <pre><code>    public void OnDrag(PointerEventData eventData)
  {
      Vector3 clickedPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
      InventoryParent.transform.position = clickedPosition;
  }
  </code></pre>
  
  <p>as the above. </p>
  
  <p>Anyone has idea on how can I do accurate mouse dragging UI with Screen-Space Camera? Doing it with overlay works fine. </p>