Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions AudioBankMounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,32 @@ public class AudioBankMounter : MonoBehaviour
{
public List<string> BanksToMount = new List<string>();

private bool loaded = false;

void Start()
{
if(AudioManager.Instance==null)
if (AudioManager.Instance == null)
{
Debug.LogWarning("There is no UberAudio Manager found");
return;
}
foreach (var bankName in BanksToMount)
{
AudioManager.Instance.LoadEventBank(bankName);
loaded = true;
}
}

void OnDestroy()
{
if(AudioManager.Instance==null)
if (AudioManager.Instance == null)
{
return;
}

foreach (var bankName in BanksToMount)
{
if(AudioManager.Instance)
if (AudioManager.Instance != null && loaded)
{
AudioManager.Instance.UnloadEventBank(bankName);
}
Expand Down
2 changes: 1 addition & 1 deletion AudioBankMounter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AudioEmitter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 134 additions & 0 deletions AudioEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}
}

}
11 changes: 11 additions & 0 deletions AudioEvent.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AudioEventBank.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 3 additions & 132 deletions AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,136 +7,6 @@

namespace UberAudio
{
//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;
}
}

}

//The core UberAudio manager singleton
public class AudioManager : MonoBehaviour
Expand Down Expand Up @@ -174,14 +44,15 @@ public static string MakeEvent(string s1, params object[] vars)
//Set up our singleton.
public void Awake()
{
if(Instance!=null)
if (Instance != null)
{
Destroy(gameObject);
}
else
{
Instance = this;
UnityEngine.Object.DontDestroyOnLoad(gameObject);
name = "uberaudio_singleton";
DontDestroyOnLoad(gameObject);
}
}

Expand Down
2 changes: 1 addition & 1 deletion AudioManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Editor/AudioEditorTools.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading