-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added choice for starting FMOD event
- Loading branch information
Showing
8 changed files
with
158 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using UnityEngine; | ||
|
||
public class AudioControlEventStarter : MonoBehaviour | ||
{ | ||
public string signalName; | ||
|
||
void OnCollisionEnter(Collision col) { | ||
EventSignaling.TriggerEvent(signalName); | ||
} | ||
|
||
void OnTriggerEnter(Collider col) { | ||
EventSignaling.TriggerEvent(signalName); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,9 @@ public enum Axis | |
x, | ||
y, | ||
z | ||
} | ||
|
||
public enum StartMode { | ||
Automatic, | ||
Triggered | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
public class EventSignaling : MonoBehaviour { | ||
|
||
private Dictionary <string, UnityEvent> eventDictionary; | ||
|
||
private static EventSignaling eventSignaling; | ||
|
||
public static EventSignaling instance | ||
{ | ||
get | ||
{ | ||
if (!eventSignaling) | ||
{ | ||
eventSignaling = FindObjectOfType (typeof (EventSignaling)) as EventSignaling; | ||
|
||
if (!eventSignaling) | ||
{ | ||
Debug.LogError ("There needs to be one active EventSignaling script on a GameObject in your scene."); | ||
} | ||
else | ||
{ | ||
eventSignaling.Init (); | ||
} | ||
} | ||
|
||
return eventSignaling; | ||
} | ||
} | ||
|
||
void Init () | ||
{ | ||
if (eventDictionary == null) | ||
{ | ||
eventDictionary = new Dictionary<string, UnityEvent>(); | ||
} | ||
} | ||
|
||
public static void StartListening (string eventName, UnityAction listener) | ||
{ | ||
UnityEvent thisEvent = null; | ||
if (instance.eventDictionary.TryGetValue (eventName, out thisEvent)) | ||
{ | ||
thisEvent.AddListener (listener); | ||
} | ||
else | ||
{ | ||
thisEvent = new UnityEvent (); | ||
thisEvent.AddListener (listener); | ||
instance.eventDictionary.Add (eventName, thisEvent); | ||
} | ||
} | ||
|
||
public static void StopListening (string eventName, UnityAction listener) | ||
{ | ||
if (eventSignaling == null) return; | ||
UnityEvent thisEvent = null; | ||
if (instance.eventDictionary.TryGetValue (eventName, out thisEvent)) | ||
{ | ||
thisEvent.RemoveListener (listener); | ||
} | ||
} | ||
|
||
public static void TriggerEvent (string eventName) | ||
{ | ||
UnityEvent thisEvent = null; | ||
if (instance.eventDictionary.TryGetValue (eventName, out thisEvent)) | ||
{ | ||
thisEvent.Invoke (); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters