title: Playing multiple audio clips in unity
body: <p>There might be similar questions to this one but I couldn't find any useful.</p>
  
  <p>I have a simple scrips which has a list of classes that contains audio clips, id, and event system individually for each one of those elements.</p>
  
  <p>I need to make that audio clip fields to list and make them play by order until the last one then stop and fire event.</p>
  
  <p>Here's my code for only one audio clip slot:
  (Also i tried audio clip array but its just playing the first one on the audio clip array)</p>
  
  <pre><code>public class MainAudioManager : MonoBehaviour {
  
  
  public List&lt;soundInfo&gt; currentsoundinfoList = new List&lt;soundInfo&gt;();
  
  AudioSource audioSource;
  
  soundInfo curentSoundInfo;
  
  float audioLenght;
  
  
  void Start () {
  
  
      audioSource = gameObject.GetComponent&lt;AudioSource&gt; ();
  
  }
  
  
  public void SetAudioToPlay (int ID) {
  
  
      for (int i = 0; i &lt; currentsoundinfoList.Count; i++) {
  
          if (currentsoundinfoList [i].ID == ID) {
  
              curentSoundInfo = currentsoundinfoList[i];
  
              audioSource.clip = curentSoundInfo.clipToPlay;
  
              audioSource.Play ();
  
              audioLenght = audioSource.clip.length;
  
              StartCoroutine ("waitnigTillEbd");
  
  
              return;
  
          }
  
      }
  
  
  }
  
  
  IEnumerator waitnigTillEbd () {
  
  
  
      yield return new WaitForSeconds (audioLenght + 1f);
  
      curentSoundInfo.eventOnSound.Invoke ();
  
  }
  
  
  [System.Serializable]
  
  public class soundInfo {
  
  
      public string name;
  
      public int ID;
  
      public AudioClip clipToPlay;
  
      public UnityEvent eventOnSound;
  
  }
  </code></pre>
  
  <p>}</p>