Search Unity

Most efficient way to play lots of audio clips?

Discussion in 'Audio & Video' started by PixelKnights, Apr 28, 2016.

  1. PixelKnights

    PixelKnights

    Joined:
    Feb 24, 2016
    Posts:
    15
    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
     
  2. michaelhartung

    michaelhartung

    Joined:
    Dec 19, 2013
    Posts:
    72
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    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.
     
    michaelhartung likes this.
  4. michaelhartung

    michaelhartung

    Joined:
    Dec 19, 2013
    Posts:
    72
    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.