36 lines
862 B
C#
36 lines
862 B
C#
using UnityEngine;
|
|
using UnityEngine.Audio;
|
|
using AudioSourceEvents;
|
|
using System;
|
|
using UnityEngine.Events;
|
|
|
|
public class NarratorVO : AudioSourceObserver
|
|
{
|
|
public AudioSource narratorAudioSource;
|
|
public AudioResource firstNarration;
|
|
public UnityEvent narrationFinished;
|
|
|
|
private IAudioEventSource _eventSource;
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
PlayNarrationAudio();
|
|
}
|
|
|
|
void PlayNarrationAudio()
|
|
{
|
|
_eventSource = narratorAudioSource.RequestEventHandlers();
|
|
_eventSource.AudioStopped += NarrationFinished;
|
|
|
|
narratorAudioSource.resource = firstNarration;
|
|
narratorAudioSource.Play();
|
|
}
|
|
|
|
private void NarrationFinished(object sender, EventArgs e)
|
|
{
|
|
narrationFinished.Invoke();
|
|
}
|
|
|
|
}
|