Advertisement
dronkowitz

OmochaoTrigger.cs

Aug 7th, 2021 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class OmochaoTrigger : MonoBehaviour
  6. {
  7.     public List<AudioClip> dialogs = new List<AudioClip>();
  8.     public AudioSource asource;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.  
  13.     }
  14.  
  15.     // Update is called once per frame
  16.     void Update()
  17.     {
  18.  
  19.     }
  20.     public IEnumerator ReadDialog()
  21.     {
  22.        
  23.         int counter = 0;
  24.         while (counter < dialogs.Count)
  25.         {
  26.             asource.clip = dialogs[counter];
  27.             asource.Play();
  28.             while (asource.isPlaying)
  29.             {
  30.                 yield return new WaitForSeconds(Time.deltaTime);
  31.             }
  32.             counter += 1;
  33.         }
  34.         yield return null;
  35.     }
  36.     public void Dialogread()
  37.     {
  38.         StartCoroutine(ReadDialog());
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement