Sie sind auf Seite 1von 4

Adding Button Sounds to your buttons (onMouseover) in Atavism.

Step 1. In your Hierarchy view, add a NEW, EMPTY GAMEOBJECT.

Step 2. Set this new Gameobject’s position to 0, 0, 0 in the inspector so it resides next to
the Main Camera. Alternatively, you could child it to the camera.

Step 3. Give your new Gameobject a name, In my case, I named it buttonSounds.

Step 4. Make your new Gameobject an Audio Source by Adding the Audio Source
Component it.
Add Component > Audio > Audio Source
Step 5. Add the sound you would like to play when you mouseover your buttons to the
Audio Source Component, in the Audio Clip slot.
In my case, I used a sound called “ui_select_2”.

Uncheck Play on Awake and Loop.

Step 6. In your Hierarchy view, Go to the UI Canvas and select the button you wish to
add mouseover sounds to.

Here I chose the Quit Button.

Step 7. Add an Event Trigger Component to the button.

Add Component > Event > Event Trigger


Step 8. In the Event Trigger Component you just added, click the Add Event Type
button and add a Pointer Enter Event to the trigger.

Add New Event Type > Pointer Enter

Step 9. In the Event Trigger Component you just added, click the plus sign (+) in the
bottom right corner to add a new Pointer Enter event to the list.

Plus Sign (+) > Pointer Enter

Step 10. In the Event Trigger Component, Choose when the event should occur.
In my case I chose only at Runtime.

Drag your buttonSounds Gameobject from the Heirarchy view that we created in Steps
1 through 5, to the Event Triggers Object Slot.
Step 11. In the Event Trigger Component, Add a PlayOneShot (AudioClip) funtion.

No Function > Audio Source > PlayOneShot (AudioClip)

Step 12. Press play and mouse over your button to enjoy bringing your UI to life with
sound events!

NOTES

If you are using different sounds for each button, this entire provcess needs to be
repeated for each button.

If you want a sound to play when you press your button, simply do steps 1 - 5.
Then in the onClick event provided with Atavism, add a new event and do the
triggering there!

Das könnte Ihnen auch gefallen