Hey,
I’m working on a 2D platformer and each rooms are new scenes, to prevent the ambient sounds from getting cut off during scene transitions i created a persistent level that is always active, and i’ve placed the ambient audio sources there, this way i’m able to hear a waterfall that is in another scene from a distance, for example.
My issue is that having the whole game’s ambient sounds loaded in the memory sounds like a bad idea, and even if i only activated the audiosources when in range, the inactive audiosources would still have their audioclip loaded into the memory.
I’d like to know if it is possible to fill my whole gigantic persistent level with audio sources and not have them use any resources until the player is in hearing range, if not , do you guys have any suggestions?
Thanks
I haven't heard of this before, most people have suggested that i use Resources.Load to load and unload clips from memory, when Preload Audio Data is set to false, an audio source won't have the audio clip taking memory at all until i call AudioClip.LoadAudioData? So loading it and unloading it should work with a trigger?
– Khena_BI've set Preload audio data to false and the audio clip still plays on awake.
– Khena_BIt seems to work when i play, load and unload it manually, but when i call clip.UnloadAudioData(); I get a really long freeze, is it possible to unload the audio data without getting a big lag spike?
– Khena_BFor some reason my OnTriggerEnter2D was being called repeatedly and loading the clip multiple times, once fixed and loaded once only, it can be unloaded without a hitch I'll mark this as an answer, i'll have to run some tests but it seems to be the best solution so far, thanks for the help slavo.
– Khena_B