Multiple audio samples on one object.

I need your help. I’m trying to learn C#.
I want to do that on a one single object were three audio samples and when I click on object with mouse button - sounds were played back in sequence. First click = sound 1, second click = sound 2, third click = sound 3…and again first click = sound 1.

I’m trying to make this so:

public AudioClip sound1;
public AudioClip sound2;
public AudioClip sound3;
void OnMouseDown ()

But I don’t understand how to play another two audio in sequence.
I also need that when I released the mouse button the sound faded using 1 second audio fade-out. How can I make this fadeout?

Help me please.

Put the AudioClip’s in a built-in array and use a pointer which you increment and reset when it has reached the length of the AudioClip array. Make use of coroutines to play, fade in and fade out the sound.

Read [this article][1] about arrays and how you can work with them. What I usually do when I have a pointer in an array is to increment it with a remainder to reset it to zero when exceeded the length of the array. For instance:


i++; i=i%audioClipArray.Length;
Next step is [volume][2], an AudioSource can only play one clip at a time as far as I know, so use two AudioSources. During the length of the audio you fade in and fade out the sound, for instance have a look at [Duck’s answer][3] on this issue to get you started. A [coroutine][4] will make excellent use in this case.
[2]: Unity - Scripting API: AudioSource.volume
[3]: Is there a way I fade in/out audio in an "if" statement? - Unity Answers
[4]: Unity - Manual: Coroutines