title: How to detect if the mouse is over the object Unity C#
body: <p>I have been working on a game in Unity 3D, which involves being able to pick up some objects.  My current code is as follows:</p>
  <pre><code>using System.Collections;
  </code></pre>
  <p>using System.Collections.Generic;
  using UnityEngine;</p>
  <pre><code>public class pickUp : MonoBehaviour
  {
    public Transform dest;
    void OnMouseDown() {
        GetComponent&lt;Rigidbody&gt;().useGravity = false;
        GetComponent&lt;Rigidbody&gt;().velocity = new Vector3(0f, 0f, 0f);
        GetComponent&lt;Rigidbody&gt;().angularVelocity = new Vector3(0f, 0f, 0f);
        this.transform.position = dest.position;
        this.transform.parent = GameObject.Find(&quot;Destination&quot;).transform;
      }
  
    void OnMouseUp() {
      this.transform.parent = null;
      GetComponent&lt;Rigidbody&gt;().useGravity = true;
    }
    void Update() {
  //where I need to detect mouseover    
    }
  }
  </code></pre>
  <p>I need to, as implied in the comment, detect if the mouse is down over the object because otherwise it turns off physics for all other objects.  I also cannot program the name (so using Ray) since so many objects already use the script.</p>
  <p>Thanks!</p>
  <p>Edit: old version of code, put current version in</p>