First, an empty game object was placed in the scene at 0, 0, 0. This empty game object contained the audio source of the sound we wanted to play for our purpose and it was ensured that the audio source would not play immediately and would not loop by un-ticking those selections.
Then on every button in the scene (in this case the Main Menu) an Event Trigger was added and a "new event type", all of which the same, the event type being "Pointer Enter". All of the buttons then took the empty game object created as a reference and then through a drop down menu chose "AudioSource.Play()". The logic here is:
Pointer Enter (Mouse Pointer) > AudioSource.Play
Play the referenced audio, in this case the audio desired to be played when the player mouses over the buttons and only play once as Loop has been un-ticked previously.
This technique of applying SFX to our buttons was used for all of the buttons in the Unity project.
No comments:
Post a Comment