Documentation for the Unity C# Library
Loading...
Searching...
No Matches
SetFxVolume.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using PixoVR.Audio;
5using PixoVR.Core;
6using UnityEngine;
7
8namespace PixoVR.Event
9{
13 public class SetFxVolume : IStep
14 {
15 private readonly AudioService _audioService;
16
17 public event Action OnFunctionFinished;
18
19 public SetFxVolume()
20 {
22 }
23
24 public void StartStep(StepItem stepItem, StepFunction function, List<InteractableClass> interactables = null,
25 Action onStepSkipped = null)
26 {
27 Debug.Log("SetVoiceOverVolume : IStep VO:" + function.value);
28
30
31 if (function.additionalValues.Length == 0)
32 {
33 Debug.LogError("Audio additionalValues value not added");
34
35 return;
36 }
37
38 var volume = function.additionalValues[0];
39 var fxName = function.value;
40
41 if (string.IsNullOrEmpty(fxName))
42 {
43 Debug.LogError("FxName is empty");
44
45 return;
46 }
47
48 if (string.IsNullOrEmpty(volume))
49 {
50 Debug.LogError("Audio volume value is empty");
51
52 return;
53 }
54
55 float volumeValue = float.Parse(volume, System.Globalization.CultureInfo.InvariantCulture);
56 _audioService.SetSfxVolume(fxName,volumeValue);
57 }
58
59 public void FunctionFinished()
60 {
61 OnFunctionFinished?.Invoke();
62 }
63 }
64}
Main logic for playing fxs and voice overs.
void SetSfxVolume(int audioID, float volume)
Set fx volume by audio id.
Unity components communication service.
Change general fxs volume function.
void FunctionFinished()
Called to end current step and start a next one.
void StartStep(StepItem stepItem, StepFunction function, List< InteractableClass > interactables=null, Action onStepSkipped=null)
readonly AudioService _audioService
[Serializable]
Definition StepItem.cs:12
Basic interface of functions. (Please note that iStep is a wrong name)
Definition IStep.cs:10