forked from bbbscarter/UberAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioEvent.cs
More file actions
134 lines (124 loc) · 4.98 KB
/
AudioEvent.cs
File metadata and controls
134 lines (124 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using UnityEngine;
using UnityEngine.Audio;
//And audio event, mapping a audio settings to a string event
[Serializable]
public class AudioEvent
{
public string EventName;
public float RandomWeight = 1.0f;
public float Volume = 1.0f;
public AudioClip AudioClip = null;
public int Priority = 128;
public int GroupID = 0;
public bool Loop = false;
public bool StopWhenSourceDies = false;
public bool KeepLoopingWhenSourceDies = false;
public bool DoNotTrackSourceMovement = false;
public bool BypassEffects = false;
public bool BypassListenerEffects = false;
public bool BypassReverbZones = false;
public float DopplerLevel = 1.0f;
public float MaxDistance = 500.0f;
public float MinDistance = 1.0f;
public bool Mute = false;
public AudioMixerGroup OutputAudioMixerGroup = null;
public float PanStereo = 0.0f;
public float Pitch = 1.0f;
public bool Spatialize = false;
public AudioRolloffMode RolloffMode = AudioRolloffMode.Logarithmic;
public AnimationCurve CustomRolloffCurve;
public float SpatialBlend = 0.0f;
public float ReverbZoneMix = 1.0f;
[System.NonSerialized]
public string BankName;
//Used by the AudioEventEditor 'Clone'
//Duplicates an AudioEvent.
//TODO - Do this via reflection.
public AudioEvent Clone()
{
var ev = new AudioEvent();
ev.RandomWeight = RandomWeight;
ev.Volume = Volume;
ev.AudioClip = AudioClip;
ev.EventName = EventName;
ev.Loop = Loop;
ev.StopWhenSourceDies = StopWhenSourceDies;
ev.Priority = Priority;
ev.GroupID = GroupID;
ev.KeepLoopingWhenSourceDies = KeepLoopingWhenSourceDies;
ev.DoNotTrackSourceMovement = DoNotTrackSourceMovement;
ev.BypassEffects = BypassEffects;
ev.BypassListenerEffects = BypassListenerEffects;
ev.BypassReverbZones = BypassReverbZones;
ev.DopplerLevel = DopplerLevel;
ev.MaxDistance = MaxDistance;
ev.MinDistance = MinDistance;
ev.Mute = Mute;
ev.OutputAudioMixerGroup = OutputAudioMixerGroup;
ev.PanStereo = PanStereo;
ev.Pitch = Pitch;
ev.RolloffMode = RolloffMode;
ev.CustomRolloffCurve = CustomRolloffCurve;
ev.SpatialBlend = SpatialBlend;
ev.ReverbZoneMix = ReverbZoneMix;
ev.Spatialize = Spatialize;
return ev;
}
//Transfers audio settings to an audio source
public void TransferToAudioSource(AudioSource source)
{
source.loop = Loop;
source.volume = Volume;
source.clip = AudioClip;
source.bypassEffects = BypassEffects;
source.bypassListenerEffects = BypassListenerEffects;
source.bypassReverbZones = BypassReverbZones;
source.dopplerLevel = DopplerLevel;
source.maxDistance = MaxDistance;
source.minDistance = MinDistance;
source.mute = Mute;
source.outputAudioMixerGroup = OutputAudioMixerGroup;
source.panStereo = PanStereo;
source.pitch = Pitch;
source.priority = Priority;
source.rolloffMode = RolloffMode;
source.spatialBlend = SpatialBlend;
source.reverbZoneMix = ReverbZoneMix;
source.spatialize = Spatialize;
if(RolloffMode == AudioRolloffMode.Custom)
{
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, CustomRolloffCurve);
}
}
//Transfers audio settings from an AudioSource. Only used in the editor
public void TransferFromAudioSource(AudioSource source)
{
Loop = source.loop;
Volume = source.volume;
AudioClip = source.clip;
BypassEffects = source.bypassEffects;
BypassListenerEffects = source.bypassListenerEffects;
BypassReverbZones = source.bypassReverbZones;
DopplerLevel = source.dopplerLevel;
MaxDistance = source.maxDistance;
MinDistance = source.minDistance;
Mute = source.mute;
OutputAudioMixerGroup = source.outputAudioMixerGroup;
PanStereo = source.panStereo;
Pitch = source.pitch;
Priority = source.priority;
RolloffMode = source.rolloffMode;
SpatialBlend = source.spatialBlend;
ReverbZoneMix = source.reverbZoneMix;
Spatialize = source.spatialize;
if(RolloffMode == AudioRolloffMode.Custom)
{
CustomRolloffCurve = source.GetCustomCurve(AudioSourceCurveType.CustomRolloff);
}
else
{
CustomRolloffCurve = null;
}
}
}