Random Audio Clips on Audio Source.

Would it make sense to allow Audio Source to define an array of Audio Clips instead of just one? Then allow the user to select one clip, or a random check box?

If that makes perfect sense. What would be the best way for me to accomplish the same thing?

Do I have to duplicate the Audio Source functionality in a class of my own? Or is there a better way using the current Audio Source class.

Or would it be a better design to create a “AudioSourceRandomizer” class that allows the designers to assign a list of audio sources? This seems too convoluted.

Has any one come across this and came up with a clean design?

Thanks

Sure.

Just use standard programming techniques for arrays?

var someAudioClips : AudioClip[];

Then pick from that using Random.Range. Or are you asking something else?

–Eric

I am asking something else. That is the easy way for me, the programmer :slight_smile: But I am thinking of the designers. So right now they drop an Audio Source on an Game Object and add an Audio clip. I want to keep that “system” as consistent and intuitive as possible. I honestly wish I could extend Audio Source.

Write a script that contains a public reference to the array as @Eric5h5 indicated, and then your script can randomly choose one to play. Your designers can just change the array length as needed and assign their desired audio clips.