Search Unity

OnMouseEnter not working on GUI objects.

Discussion in 'Scripting' started by Kinth, Jul 4, 2015.

  1. Kinth

    Kinth

    Joined:
    Mar 20, 2015
    Posts:
    22
    I'm trying to use OnMouseEnter() with GUI objects but it never seems to fire.

    The object is a GUI Image with a script attached. According to the documentation OnMouseEnter should work with GUI elements. As far as I am aware the Image is a GUI element. I've tried adding a collider to the object and it still does not work. I tested the script with a non GUI object and it works fine. Is there anything extra I need to do to get it to trigger with GUI elements?
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    are you using canvases?

    if so you're not using GUIElements, you are using UnityEngine.UI...
     
  3. Kinth

    Kinth

    Joined:
    Mar 20, 2015
    Posts:
    22
    ahhh I see. Is there anyway to get mouse over to work with UI? At the moment I have used a set of event triggers but it seems to be a messy way of doing it.
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860