Skip to content

Commit

Permalink
Merge pull request #500 from HodgsonSDAS/HTK-audio
Browse files Browse the repository at this point in the history
UAudioManager added null check in PlayEvent
  • Loading branch information
Stephen Hodgson committed Feb 6, 2017
2 parents 404ba99 + 9eef801 commit 370089f
Showing 1 changed file with 11 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,7 @@ public void PlayEvent(string eventName)
/// <param name="messageOnAudioEnd">The Message to Send to the GameObject when the sound has finished playing.</param>
public void PlayEvent(string eventName, GameObject emitter, string messageOnAudioEnd = null)
{
PlayEvent(
eventName,
emitter,
null,
null,
messageOnAudioEnd);
}

/// <summary>
/// Plays an AudioEvent.
/// </summary>
/// <param name="eventName">The name associated with the AudioEvent.</param>
/// <param name="primarySource">The AudioSource component to use as the primary source for the event.</param>
public void PlayEvent(string eventName, AudioSource primarySource)
{
PlayEvent(eventName, primarySource, null);
PlayEvent(eventName, emitter, null, null, messageOnAudioEnd);
}

/// <summary>
Expand All @@ -97,14 +82,9 @@ public void PlayEvent(string eventName, AudioSource primarySource)
/// <param name="eventName">The name associated with the AudioEvent.</param>
/// <param name="primarySource">The AudioSource component to use as the primary source for the event.</param>
/// <param name="secondarySource">The AudioSource component to use as the secondary source for the event.</param>
public void PlayEvent(string eventName,
AudioSource primarySource,
AudioSource secondarySource)
public void PlayEvent(string eventName, AudioSource primarySource, AudioSource secondarySource = null)
{
PlayEvent(eventName,
primarySource.gameObject,
primarySource,
secondarySource);
PlayEvent(eventName, primarySource.gameObject, primarySource, secondarySource);
}

/// <summary>
Expand All @@ -115,11 +95,7 @@ public void PlayEvent(string eventName,
/// <param name="primarySource">The AudioSource component to use as the primary source for the event.</param>
/// <param name="secondarySource">The AudioSource component to use as the secondary source for the event.</param>
/// <param name="messageOnAudioEnd">The Message to Send to the GameObject when the sound has finished playing.</param>
private void PlayEvent(string eventName,
GameObject emitter,
AudioSource primarySource,
AudioSource secondarySource,
string messageOnAudioEnd = null)
private void PlayEvent(string eventName, GameObject emitter, AudioSource primarySource, AudioSource secondarySource, string messageOnAudioEnd = null)
{
if (!CanPlayNewEvent())
{
Expand All @@ -132,11 +108,17 @@ private void PlayEvent(string eventName,
emitter = gameObject;
}

if (string.IsNullOrEmpty(eventName))
{
Debug.LogWarning("Audio Event string is null or empty!");
return;
}

AudioEvent currentEvent;

if (!eventsDictionary.TryGetValue(eventName, out currentEvent))
{
Debug.LogFormat( "Could not find event \"{0}\"", eventName);
Debug.LogFormat("Could not find event \"{0}\"", eventName);
return;
}

Expand Down

0 comments on commit 370089f

Please sign in to comment.