Search Unity

Too Many Audio Clips

Discussion in 'Audio & Video' started by jroto23, Nov 5, 2015.

  1. jroto23

    jroto23

    Joined:
    Oct 19, 2015
    Posts:
    82
    I have at least 15 different sounds my I want my character to make. Every time I add a new sound I create a public AudioClip object in my script and then drag the wave file to it. Is there a better way of doing this such that I can limit the number of public AudioClips to maybe just one?
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Why do you want to limit the number of public Audio Clips?
     
  3. jroto23

    jroto23

    Joined:
    Oct 19, 2015
    Posts:
    82
    Well, I can live with 15+ public slots for audio clips. I really just want to know if I'm doing it the best way. I thought maybe people create one and then through code load in what ever wav needs to be played. But this would cause a delay.

    Are you saying that a public slot for each sound effect my character will make is the way to do it?
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Nothing wrong with having a bunch of Audio Clips in the Inspector.

    Playing the sounds though, it depends on how many of the sounds should be able to overlap or be interruptible.

    If you need the ability to have some of the sounds overlap, you'll need multiple Audio Sources as well, unless you want to fire and forget with Playoneshot. That gives up the ability to manipulate and stop the sounds after they start though.

    You could use the "preload audio data" turned off to save audio memory, but if you don't release the memory afterward (through code) the memory will be permanently taken up after played the first time.

    Having said all that, our plugin Master Audio handles all this for you with usually no coding.