Hi,
I'm not quite certain if this is a AC issue or not, but I've attempted something pretty simple and I don't know why its not working:
I've created a custom menu using a Unity UI prefab (linked canvas). Everything works well in terms of functionality, but when I try to add a simple AudioSource to the canvas prefab so that it plays on "awake", the sound refuses to play.
What am I missing?
Thanks!
Comments
It's possible my initial question was unclear so here's a more specific question:
I've created a new menu using this tutorial: https://adventurecreator.org/tutorials/creating-inventory-bar-unity-ui
Now, let's say I added an animation (glow effect) when the inventory bar first appears. How do I add a sound to that?
The best way to play audio when a menu appears is to assign an ActionList when turn on asset file within that menu's properties. Set the asset's When running field to Run In Background, and give it a single Sound: Play Action.
If you don't specify a Sound object within that Action, it will rely on the Default Sound prefab that can be defined at the top of the Scene Manager.
I guess I'm trying to understand how it could work a bit more broadly.
For greater control with respect to animation syncing, you could rely on Animation events to run an ActionList asset at a given time.
Now, Unity's animation events can only be used to invoke methods on components attached to the same Animator object - while ActionLists can only exist as prefabs via separate asset files. However, you can get around this by doing the following: