title: OnMouseOver In Unity
body: <p>quick question I got this script here to show the name of an Item you collect. These names are made public so I can change them within the item list. What I want to do Is to walk into an item and hover my mouse over the item so it can display the name of the item in the middle of the screen. I don't know if I should use a trigger, or a GUILayout or however. Please Help and thanks. Here is the Script: <strong>UPDATED</strong></p>
  
  <pre><code>public class RayCasting : MonoBehaviour
  {
  public float pickupDistance;
  public List&lt;Item&gt; items;
  //public List&lt;Keybutton&gt; buttons;
  
  #region Unity
  void Start ()
  {
      Screen.lockCursor = false;
  
      for (int i = 0; i &lt; items.Count; i++) {
          Item temp = items[i];
          int randomIndex = Random.Range(i, items.Count);
          items[i] = items[randomIndex];
          items[randomIndex] = temp;
      }
  }
  void Update ()
  {
              RaycastHit hit;
              Ray ray = new Ray (transform.position, transform.forward);
              if (Physics.Raycast (ray, out hit, pickupDistance)) {
                      foreach (Item item in items) {
  
                              if (Input.GetMouseButtonDown (0)) {
                                      if (item.gameObject.Equals (hit.collider.gameObject)) {
                                              numItemsCollected++;
                                              item.Collect ();
                                              break;
                                      }
  
                              }
                      }
              }
      }
  
  void OnGUI()
  {
  
      GUI.backgroundColor = Color.blue;
      GUI.Box(new Rect(120,390,170,250),"Text Message");
      GUILayout.BeginArea(new Rect(132,432,100,170));
      {
          GUILayout.BeginVertical();
          {
      if (numItemsCollected &lt; items.Count)
      {
          foreach (Item item in items)
  
                      GUILayout.Label(string.Format("[{0}] {1}", item.Collected ? "" + item.password: " ", item.name ));
  
      }
      else
      {
      foreach (Item item in items)
  
                      GUILayout.Label(string.Format("[{0}] {1}", item.Collected ? "" + item.password: " ", item.name ));          
                  //GUILayout.Label("Take code to KeyPad");
      }
          }
          GUILayout.EndVertical();
  }
      GUILayout.EndArea();
  
      //Enter Code to unlock doors.
  
                      if (GUI.Button (new Rect (250, 830, 100, 50), "Enter Code"))
                      if (numItemsCollected &gt; items.Count) {              
                              Debug.Log ("Entering Code");
                  }
  }
  
  #endregion
  
  #region Private
  private int numItemsCollected;
  #endregion
  }
  
  [System.Serializable]
  public class Item
  {
  public string name;
  //public GUIText textObject;
  public GameObject gameObject;
  public float guiDelay = 0.1f;
  
  private float lastHoverTime = -99.0f;
  public int password;
  
  public bool Collected { get; private set; }
  
  
  
  public void Collect()
  {
      Collected = true;
      //gameObject.SetActive(false);
  }
  
  public void passwordNumber()
  {
      password = 0;
      Collected = true;
      gameObject.SetActive(false);
  }
  
  void OnMouseEnter ()
  {
      lastHoverTime = Time.timeSinceLevelLoad;
  }
  
  void OnGUI(){
              if (lastHoverTime + guiDelay &gt; Time.timeSinceLevelLoad) {
                      GUI.Box (new Rect (300, 300, 170, 250), name);
              }
      }
  }
  </code></pre>