-
Notifications
You must be signed in to change notification settings - Fork 546
Event System
The framework provides GlobalEvent
classes to dispatch events
Enumeration as Key
static void AddEvent (Enum type, EventHandle handle, bool isUseOnce = false)
Register an event listener
static void RemoveEvent (Enum type, EventHandle handle)
Removes an event listener
static void RemoveEvent (Enum type)
Removes some type of event listener
static void DispatchEvent (Enum type, params object [] args)
Dispatch event
String as Key
static void AddEvent (string eventKey, EventHandle handle, bool isUseOnce = false)
Register an event listener
static void RemoveEvent (string eventKey, EventHandle handle)
Removes an event listener
static void RemoveEvent (string eventKey)
Remove some kind of event listener
static void DispatchEvent (string eventKey, params object [] args)
Dispatch event
generic method
static void AddTypeEvent <T> (EventHandle <T> handle, bool isUseOnce = false)
Register an event listener
static void RemoveTypeEvent <T> (EventHandle <T> handle, bool isUseOnce = false)
Removes an event listener
static void RemoveTypeEvent <T> (bool isUseOnce = false)
Remove some kind of event listener
static void DispatchTypeEvent <T> (T e, params object [] args)
Dispatch events
static void RemoveAllEvent ()
Removes all event listeners
GlobalEvent.AddEvent (MemoryEvent.FreeHeapMemory, CleanCache);
GlobalEvent.DispatchEvent (MemoryEvent.FreeHeapMemory);
GlobalEvent.RemoveEvent (MemoryEvent.FreeHeapMemory, CleanCache);
GlobalEvent.AddEvent ("GameStart", ReceviceGameStart);
GlobalEvent.DispatchEvent ("GameStart");
GlobalEvent.RemoveEvent ("GameStart", ReceviceGameStart);
GlobalEvent.AddTypeEvent <SyncEntityMsg> (ReceviceSyncEntity);
GlobalEvent.DispatchTypeEvent (new SyncEntityMsg ());
GlobalEvent.RemoveTypeEvent <SyncEntityMsg> (ReceviceSyncEntity);