Hey everyone, I was wondering if anyone has dealt with this. I have a menu which starts playing music for a collection of sub-menus, all of which are popups including the menu itself. 80% of the time, the system works. However, sometimes after closing the popup menu which hosts the sub-popups, the root popup menu fails to stop the music. It’s not predictable at all. It seems like the reference to a sound which is started in one instance of monarch.show isn’t preserved when that menu is hidden then shown again. I have no way to keep a reference to it since the menu is lost and re-initialized on re-entry. Does anyone know of a way I can fix it? I tried using singletons but this doesn’t help since the reference to the music is lost.
I don’t quite understand the situation. You play a sound component, unload a proxy, then load it again and try to stop the sound component?
I keep audio components in their own collections in my projects outside of screen collections. You might consider using FMOD too since it may have other benefits for your project as well.
I’d have to experiment with this but I am expecting that if you do sound.play(“sounds#tadaa”) and then unload the collection (ie using the collection proxy) the sound would stop.
If you on the other hand use a collection factory or for that matter a game object factory and spawn a game object with a sound component, play the sound and delete the game object the sound would still play.
What is the root popup menu? A collection spawned/loaded from a collection factory or a collection proxy?
This is usually good advice as it makes it easy to handle sound playback in the entire project with muting/unmuting, fading sounds etc. But for a very big project you might not want all sounds loaded at the same time? But I wouldn’t worry about that until it becomes a problem.
If you on the other hand use a collection factory or for that matter a game object factory and spawn a game object with a sound component, play the sound and delete the game object the sound would still play.
This is my case. The menus are collectionfactories so I need some way to hold onto the reference in order to stop the sound when that menu is re-created and then exited by the user, not by a sub-menu. I spent a couple of hours trying various solutions but nothing took. I tried not clearing the popup in Monarch and this fixes the sound issue but it causes tons of issues in all my other sub-menus since they weren’t designed for it. Also, I had to set the background to a solid color to conceal the non-hidden UI screen and I’d prefer to have the menus semi-transparent.
EDIT: I tried moving songs to my main object. For some reason some songs work to switch to and others don’t. It seems like it only works if I switch songs from the scripts but not from gui_scripts.
Can you isolate this into a small example for us to try?
We do in FSR and FSD currently and on PC it works even though memory usage is a little higher than FSH. I have plans to test async loading system as needed now that audio is threaded but have not done yet (I worry that the game sim may still hang as songs change so will need to test). It would still mean audio is in one place for us but we can have only 1 to a few songs loaded at once and whatever sounds are needed for a specific screen.