title: Unity - Move Canvas as a 3D GameObject
body: <p>i have a script with which i can move (on 2 axis) any 3D objects, the script i'm using is this (for mouse and touchscreen)</p>
  
  <pre><code>using UnityEngine;
  public class DragInput : MonoBehaviour {
  
  
  
      GameObject gObj = null;
      Plane objPlane;
      Vector3 mO;
      Camera cam;
  
      void Awake() {
          cam = GameObject.FindGameObjectWithTag("MyCamera").GetComponent&lt;Camera&gt;();
      }
      Ray GenerateMouseRay()
      {
          Vector3 mousePosFar = new Vector3(Input.mousePosition.x,Input.mousePosition.y,cam.farClipPlane);
          Vector3 mousePosNear = new Vector3(Input.mousePosition.x,Input.mousePosition.y,cam.nearClipPlane);
          Vector3 mousePosF = cam.ScreenToWorldPoint(mousePosFar);
          Vector3 mousePosN = cam.ScreenToWorldPoint(mousePosNear);
  
          Ray mr = new Ray(mousePosN, mousePosF-mousePosN);
          return mr;
      }
  
      // Update is called once per frame
      void Update () 
      {
          if(Input.GetMouseButtonDown(0))
          {
              Ray mouseRay = GenerateMouseRay();
              RaycastHit hit;
  
              if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out hit))
              {
                  gObj = hit.transform.gameObject;
                  objPlane = new Plane(cam.transform.forward*-1, gObj.transform.position);
  
                  //calc mouse offset
                  Ray mRay = cam.ScreenPointToRay(Input.mousePosition);
                  float rayDistance;
                  objPlane.Raycast(mRay, out rayDistance);
                  mO = gObj.transform.position - mRay.GetPoint(rayDistance);
              }
          }
          else if(Input.GetMouseButton(0) &amp;&amp; gObj)
          {
              Ray mRay = cam.ScreenPointToRay(Input.mousePosition);
              float rayDistance;
              if (objPlane.Raycast(mRay, out rayDistance))
                  gObj.transform.position = mRay.GetPoint(rayDistance) + mO;
          }
          else if (Input.GetMouseButtonUp(0) &amp;&amp; gObj)
          {
              gObj = null;
          }
      }
  }
  </code></pre>
  
  <p>If i click on any object i have created (with a box collider) i can freely move this object over the screen. Unfortunately this will not happen if the object is a World Space UI(canvas).
  Anyone can gime me some hint and tell me why i'm not able to move the space UI?</p>