Hey there- I’m trying to determine if there’s a reasonable way to manage individual sound volumes. In particular, I have a hard requirement to be able to control volume on specific instances of a given sound.
Since it looks like multiple instances of a given sound tied to the same Sound component share their gain value, the only approach I could think of was:
- Build a Factory for each discrete sound that needs hands-on management
- Route sound requests to a central manager object
- Have the appropriate factory instantiate a game object wrapping a Sound component, cache the game object reference in the manager, and trigger the sound
- (optional) - central manager may send game object wrappers commands viz. gain, etc
- When the sound is completed, the clear its cached value in the manager and delete the game object attached to it
I think that in principle this should work (though I am not going to go out of my way to call it elegant- this is the closest thing I could think of to mimic Unity-style AudioSources that are distinct from the actual sounds they play)… my concern is that I’m not familiar enough with Defold to gauge if this is going to totally hose garbage collection or not.
Is instantiating/deleting ~50 Sound components and associated structure a second an obviously terrible idea?
Thanks!