Most efficient way to play lots of audio clips?

Hi there,

I was wondering what the best way was to store + play audio clips? I have a lot of incidental audio clips to play in my game, about 20 or so voice overs for the character. Now I know I could have an array of audioclips in a script then play from that. But I was wondering, if I populate 20 audioclips into that array, do they all actually get loaded at start? If so isn’t it terribly inefficient to have about 1mb of audio just taking up memory?

Is there a better way? Should I be loading them as required from asset bundles or resources or something like that?

Thanks in advance

It depends how you setup your Audio Clips.

See Unity - Scripting API: AudioClip.preloadAudioData

You could use that to only load the data when you need it.

Yes, it does cause latency for those sounds though. They need to be loaded before they can play. And then you need to unload them from memory after they’re doing playing or they stay in memory for the duration of the Scene.

1 Like

True that. It really only makes sense in certain scenarios. Like dynamically loading/unloading dialog clips before you need em. Certainly not a solution for sth. time critical.