title: I can't drag text ui in unity
body: <p>I'm making a 2d unity game for my senior project.I wrote a drag and drop script, it's working perfectly with sprites but when I tried to use to drag and drop text or any other ui, it failed and it's not even dragging!! I appreciate your help in advance..</p>
  <p><a href="https://i.stack.imgur.com/2BIwK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2BIwK.png" alt="enter image description here" /></a></p>
  <p><strong>the code:</strong></p>
  <pre><code>    void Update()
      {
          if (!finish) { 
              curr = new Vector3(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y, this.gameObject.transform.localPosition.z);
              if (moving)
              {
                  Vector3 mousePos;
                  mousePos = Input.mousePosition;
                  mousePos = Camera.main.ScreenToWorldPoint(mousePos);
  
                  this.gameObject.transform.localPosition = new Vector3(mousePos.x - StartPosX, mousePos.y - StartPosY, this.gameObject.transform.localPosition.z);
              }
          }
  
  
      }
  
      public void OnMouseDown()
      {
          if (Input.GetMouseButtonDown(0))
          {
              Vector3 mousePos;
              mousePos = Input.mousePosition;
              mousePos = Camera.main.ScreenToWorldPoint(mousePos);
  
              StartPosX = mousePos.x - this.transform.localPosition.x;
              StartPosY = mousePos.y - this.transform.localPosition.y;
              this.transform.localScale = new Vector3(7f, 7f, 0f);
              textbox.SetActive(false);
              moving = true;
          }
  
  
      }
  
      public void OnMouseUp()
      {
          moving = false;
  
          if ((Mathf.Abs(this.gameObject.transform.position.x - correctform.gameObject.transform.position.x) &lt;= 10.5f) &amp;&amp; (Mathf.Abs(this.gameObject.transform.localPosition.y - correctform.gameObject.transform.localPosition.y) &lt;= 10.5f))
          {
              //this.transform.position = new Vector3(correctform.gameObject.transform.position.x, correctform.gameObject.transform.position.y, correctform.gameObject.transform.position.z);
  
              correctform.SetActive(true);
              finish = true;
  
              this.transform.position = new Vector3(correctform.gameObject.transform.position.x, correctform.gameObject.transform.position.y, correctform.gameObject.transform.position.z-1f);
              SpriteRenderer spriteRenderer = GetComponent&lt;SpriteRenderer&gt;();
              spriteRenderer.sprite = newSprite;
              GameObject.Find(&quot;finishmanage&quot;).GetComponent&lt;mercury&gt;().setDone();
          }
          else
          {
              textbox.SetActive(true);
              this.transform.position = new Vector3(resetPos.x, resetPos.y, resetPos.z);
              this.transform.localScale = initialScale;
          }
          
      }
  }
  </code></pre>