Documentation for the Unity C# Library
Loading...
Searching...
No Matches
PlayVoiceOver.cs
Go to the documentation of this file.
1using PixoVR.Audio;
2using PixoVR.Core;
3using System;
4using System.Collections.Generic;
5using UnityEngine;
6
7namespace PixoVR.Event
8{
12 public class PlayVoiceOver : IStep
13 {
14 public event Action OnFunctionFinished;
15
16 private readonly AudioService _audioService;
17
19 {
21 }
22
23 public void StartStep(StepItem stepItem, StepFunction function, List<InteractableClass> interactables, Action onStepSkipped = null)
24 {
25 Debug.Log("PlayVoiceOver : IStep VO:" + function.value);
26
27 var voiceOverData = _audioService.GetOverOverData(function.value);
28 if (voiceOverData == null)
29 {
30 OnFunctionFinished?.Invoke();
31 return;
32 }
33
34
35 var guideModeState = StatesService.GetState<GuideModeState>();
36 if (!guideModeState.IsModeActive)
37 {
38 if (voiceOverData.isGuided)
39 {
40 _audioService.UpdateLastRepeatable(function.value);
42 onStepSkipped.Invoke();
43 }
44 else
45 {
46 _audioService.PlayRepeatable(function.value);
48 _audioService.RepeatableAudioStopped += FunctionFinished;
49 }
50 }
51 else
52 {
54 {
55 VoiceOverName = function.value
56 });
57
58 _audioService.PlayRepeatable(function.value);
59
60 if (guideModeState.IsSoundEnabled)
61 {
63 }
64 else
65 {
67 }
68
69 _audioService.RepeatableAudioStopped += FunctionFinished;
70 }
71 }
72
73 public void FunctionFinished()
74 {
75 OnFunctionFinished?.Invoke();
76
77 _audioService.RepeatableAudioStopped -= FunctionFinished;
78 }
79 }
80
82 {
83 public string VoiceOverName { get; set; }
84 }
85}
Main logic for playing fxs and voice overs.
void UpdateLastRepeatable(string voiceOverName)
Update last repeatable Used to restore the last played audio.
void MuteRepeatableSound()
Mute repeatable sound volume.
void PlayRepeatable(string voiceOverName)
Play voice repeating it at a certain time intervals.
VoiceOverInfo GetOverOverData(string voiceOverName)
Get voice over data Info by name If VO data is missing from the data, it will return an error.
void SetRepeatableSoundVolume(float volume)
Set repeatable sound volume.
Intentionally made partial, in case you want to extend it easily.
Unity components communication service.
Voice over play function.
void FunctionFinished()
Called to end current step and start a next one.
void StartStep(StepItem stepItem, StepFunction function, List< InteractableClass > interactables, Action onStepSkipped=null)
readonly AudioService _audioService
Logic for saving and unloading states during project execution.
[Serializable]
Definition StepItem.cs:12
Basic interface of functions. (Please note that iStep is a wrong name)
Definition IStep.cs:10