Example 5 - Audio Player
Last updated
Last updated
This Audio Player example has been set up using a World Space Canvas, however it will work the same using a screen space canvas, but the UI elemsnts will need to be scaled differently.
Apart from moving the player to the marker, all Actions take place on the Canvas, or more specifically the Canvas UI Elements. We have used Game Creator UI Buttons to execute these actions, and a GC Slider, although it will work with a standard Unity Slider.
Firstly we have added a Unity Audio Source Object to the Canvas Plane and added a sound clip.These Actions work on Audio Source Objects and not GC Play sound Actions. We have three GC Buttons. Each calls an Action Pack 2 Action, Play, Pause, and Stop respectively.
However, on the Play Button, we have also added the Scrub Action. Both the Play and Scrub Actions can also display the Duration of the Audio (added on the Play Action) and the Current time (added on the Scrub Action). Within the Play and Scrub Actions, you add the Audio Source Object, and on the Scrub Action you add ethe Slider element.
Then press Play to start the Audio, and drag the Slider to advance the Audio.
We have also added a Visualizer that has been included in this Action Pack. This component is not controlled by Actions, but could be turned on and off with the Set Active Action within GC.
Add a Game Object to the Canvas and add the Audio Visualizer script from the Action Pack 2 Component folder.
Add a series of images and add the Audio Visualizer Object script to each (this is an empty script, just used for identification).
Withing the Audio Visualizer Script, add the Audio Source object from the canvas, set the clor, the range and the sensitivity.
Press play and readjust the settings to fit.