Game Development Reference
In-Depth Information
007 public class EventManager : MonoBehaviour
008 {
009 #region C# properties
010 //-----------------------------------
011 //Public access to instance
012 public static EventManager Instance
013 {
014 get{return instance;}
015 set{}
016 }
017 #endregion
018
019 #region variables
020 // Notifications Manager instance (singleton design pattern)
021 private static EventManager instance = null;
022
023 //Array of listeners (all objects registered for events)
024 private Dictionary<EVENT_TYPE, List<IListener>> Listeners
= new Dictionary<EVENT_TYPE, List<IListener>>();
025 #endregion
026 //-----------------------------------------------------------
027 #region methods
028 //Called at start-up to initialize
029 void Awake()
030 {
031 //If no instance exists, then assign this instance
032 if(instance == null)
033 {
034 instance = this;
035 DontDestroyOnLoad(gameObject);
036 }
037 else
038 DestroyImmediate(this);
039 }
040//-----------------------------------------------------------
041 /// <summary>
042 /// Function to add listener to array of listeners
043 /// </summary>
044 /// <param name="Event_Type">Event to Listen for</param>
045 /// <param name="Listener">Object to listen for event</param>
 
Search WWH ::




Custom Search