Before updating to Windows 10 you may need to return your Pro license. More information here

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!

more ▼

asked Jan 30, 2012 at 08:52 AM

avatar image

1 25 18 20

First off, if you refer to a java manual for unity you will have trouble. It is javascript that is used. You will have to go through a whole GUI tutorial to fix you problem. You need to create the car object and a collision with the mouse to load the application. This is not done in 10 lines unfortunately.

Jan 30, 2012 at 10:00 AM fafase
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jan 30, 2012 at 12:06 PM

avatar image

751 20 18 26

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jan 30, 2012 at 08:52 AM

Seen: 1036 times

Last Updated: Jan 30, 2012 at 12:06 PM