Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TriggerDialog : MonoBehaviour
- {
- public List<AudioClip> dialogs = new List<AudioClip>();
- private bool dialogread;
- public AudioSource omochaoTriggerDisable;
- public bool pause = false;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- private void OnTriggerEnter(Collider other)
- {
- if (dialogread == false && other.tag == "Player")
- {
- dialogread = true;
- StartCoroutine(ReadDialog());
- }
- }
- public IEnumerator ReadDialog()
- {
- int counter = 0;
- while (counter < dialogs.Count)
- {
- omochaoTriggerDisable.clip = dialogs[counter];
- omochaoTriggerDisable.Play();
- while (omochaoTriggerDisable.isPlaying || pause)
- {
- yield return new WaitForSeconds(Time.deltaTime);
- }
- counter += 1;
- }
- yield return null;
- }
- }
Add Comment
Please, Sign In to add comment