How to play the audio one by one in unity

I want to achieve playing the music one by one in Unity. I tried to create an audioClip array and want to play them one by one. And i also tried to use StartCoroutine to wait one song finished and then playing the next.

I tried to create an audioClip array and want to play them one by one. And i also tried to use StartCoroutine to wait one song finished and then playing the next.

public class AudioManager : MonoBehaviour {

    public AudioClip[] _audioClips;
    private AudioSource _audioSource;

    void Awake(){
        _audioSource = GetComponent<AudioSource>();
    }


    // Use this for initialization
    void Start () {

        for (int i = 0; i < _audioClips.Length;i++){
            _audioSource.PlayOneShot(_audioClips*);*

StartCoroutine(“WaitForMusicEnd”);
}
}

IEnumerator WaitForMusicEnd()
{
while (_audioSource.isPlaying)
{
yield return null;
}
}
However, the music will play at the same time. Please help!

Hello.

Maybe you need this:

:smiley:

Bye!