Assign a clip to an AudioSource when it finishes playing.

Hi, I’m creating an application in which I need to play different clips in an array. Just when the first clip is finished, the second one should be played. My code is the following:

public AudioClip[] clips;
private AudioSource audiosource;

void Start()
{
    audiosource = this.GetComponent<AudioSource>();
}
public void playClips()
{
    Debug.Log("hola2"); //printed
    
    for (int i=0; i < clips.Length; i++)
    {
        audiosource.clip = clips*;*

Debug.Log(clips*.ToString()); //ok*
audiosource.Play();
Debug.Log(audiosource.clip.length); //ok
Debug.Log(audiosource.isPlaying); //true ok
System.Threading.Thread.Sleep( (int) audiosource.clip.length+1); //not waiting
new WaitForSeconds(audiosource.clip.length); //not waiting

Debug.Log(audiosource.clip.length);
}
}
I tried with a yield return new WaitForSeconds(float), but my method should be void,as I am calling it from the OnClick() of a button.
Any idea of why is it not working?
Thank you in advance

Use a coroutine for that. Move all this code into a coroutine (remove that Sleep) and in your playClips method start that coroutine