how do i program the mouse over event

i’m new to java programming and i wanna program a mouse over event.
to be more specific

i want different cars to appear at mouse over event (to choose a car from five different cars)

and when you click the button i want it a go to a specific scene. so how do i program mouse over event and application.loalevel()in the same button

please help

thank u!

Just as some hints to let you know where to look…

For 2D buttons, check out the ‘GUI’ classes in Unity. These will let you make text, buttons and other 2D objects that can be clicked and hovered over. You can use custom skin and backgrounds on your ‘GUIStyle’ class to try and draw different cars, if you like.

A little more tricky but more useful is doing it in 3D.

In this case, you put all of the cars in your scene and then - in a seperate layer - put an empty GameObject with a BoxCollider over each car.

Then you would make a Unity Behaviour that uses the Physics.Raycast and Camera.ScreenToWorldPos to fire a ‘ray’ (like a fake beam of light) into your scene from the mouse cursor to see what it might be hovering over. If it strikes one of those colliders, the mouse is over the car.

It’s tricky - Unity is a 3D engine, not a 2D one. If you want a simple mouse-over on a 2D environment, I’d consider doing your game in HTML5 or Flash.