Game Development Reference
In-Depth Information
015 public class EventManager : MonoBehaviour
016 {
017 #region C# properties
018 //-----------------------------------------------------------
019 //Public access to instance
020 public static EventManager Instance
021 {
022 get{return instance;}
023 set{}
024 }
025 #endregion
026
027 #region variables
028 //Notifications Manager instance (singleton design pattern)
029 private static EventManager instance = null;
030
031 // Declare a delegate type for events
032 public delegate void OnEvent(EVENT_TYPE Event_Type,
Component Sender, object Param = null);
033
034 //Array of listener objects
035 private Dictionary<EVENT_TYPE, List< OnEvent >> Listeners
= new Dictionary<EVENT_TYPE, List< OnEvent >>();
036 #endregion
037 //-----------------------------------------------------------
038 #region methods
039 //Called at start-up to initialize
040 void Awake()
041 {
042 //If no instance exists, then assign this instance
043 if(instance == null)
044 {
045 instance = this;
046 DontDestroyOnLoad(gameObject);
047 }
048 else
049 DestroyImmediate(this);
050 }
051 //-----------------------------------------------------------
052 /// <summary>
 
Search WWH ::




Custom Search