OnMouseEnter NOT working

I have an UI text component and I want to change it's size when I touch it with the mouse. I search the API and found OnMouseEnter(). I quote "OnMouseEnter is called when the mouse entered the GUIElement or Collider.", so I understand that whatever happens will happens ONLY when the mouse touch the GUIElement or the Collider.

With this in mind I add a new component: A box collider 2D. I set the size so it wrap the text and used the following code to test if everything was ok...

but it wasn't, and I'm getting crazy because I don't understand why is not working...

I read a couple of answers and all of them points in the same direction: you don't have a collider, or, your scene is fucked up, create a new scene and try again.

I create a new scene and add a cube, attached the script to the cube and the OnMouseEnter() event work almost flawlessly. I found that if the mouse cursor passes over the cube so fast the OnMouseEnter() was never called, even if the mouse cursor passes over the cube fast first and then slowly, the OnMouseEnter() is never called... until I click the cube, then Unity3D remember that there was a box collider and an OnMouseEnter() event, and correctly redetect everytime the mouse cursor enter the box collider.

I delete the cube and add a UI button, attached the script and it didn't work... or at least thats what I thought, after moving the mouse cursor randomly aroud the screen I notice the script attached sending the info to the console, so it was working, but not when the mouse cursor entered the box collider wrapped around the button, but when it was ABOVE the button.

I reload the original main menu escene and carefully move the mouse over the "MENU" word, and once again the console show something... ABOVE THE U LETTER.

Somehow the box collider is detecting the mouse cursor way up where it should be detected.

@meat5000 I quote again ""OnMouseEnter is called when the mouse entered the GUIElement OR Collider." I'm NOT using a GUIElement as I told you. If you read http://docs.unity3d.com/ScriptReference/UI.Text.html you will see that OnMouseEnter() is available so it can be used on a Text component of the new UI. Now, if you don't use a GUIElement you must use a collider, wich is my case.

Answers can, occasionally, be a bit flaky. Questions getting stuck in moderation with no way of rejecting or approving them and such like so I was just wondering if there was something wrong with my account.

Regularly wake up to over 100 e-mails so know that feeling of not spotting one as well.

Glad it helped and glad you thanked @BoredMormon and @meat5000 as well, both good people.

OnMouseEnter is not really meant to be used with the UI system. You'll find the function will probably be deprecated in future versions.

The correct way to do this since 4.6 onwards is to implement the EventSystems.IPointerEnterHandler interface on your monobehaviour. Use the functions from this interface instead of OnMouseEnter. This also means you will need to have the appropriate GraphicsRaycaster for UI elements, and a PhysicsRacaster for regular colliders.

Your answer point me in the right direction. Instead of using OnMouseEnter() I selected the text component and added a new event trigger component, point enter type, and the function I want to call. No need for ray casting, no need for colliders, and work flawlessly no matter where the camera is or the resollution used. Thank you so much!

Go to the collider properties in the Inspector, make sure you can see the "Scene" view, adjust the collider's x, y, z and radius. Make sure it's in the same position as the GameObject you are trying to detect the collision, and make sure the "Is Trigger" option is ticked.