If Mouse cursor is above an object, start animation (without click on It)

Hi,
I have 5 planes, which are buttons of the menu, how can I do to start a simple button’s animation when the mouse cursor is on the button? (without click on it!)
Thank you :slight_smile:

If you’re using the Unity UI system, you can hook onto the IPointerEnterHandler event handler.

If not, you can try using Rect.Contains(Vector3) to check if the mouse is over the button. To do that you’ll need to convert the corners of your plane into a rect, probably using Camera.WorldToScreenPosition. Unity - Scripting API: Rect.Contains

Or, if the buttons have colliders, you could cast a ray from the mouse position into the scene to check if the cursor is over the collider. Unity - Scripting API: Input.mousePosition

Unity has a video showing how to add animations to buttons.
Just make sure to have a trigger for the Highlighted Trigger and an actual animation created using the animation editor. It can be a one frame animation. Unity will smoothly blend between them.