A very easy to use zero-gc game event sending/listen system.
-
This is useful for decoupling UI code from game code.
-
You can listen to any event that happens in your game where it inherits from IEventListener<>.
-
Sending/receiving events does not incur any unnecessary GC. (struct only)
- UniTask
Movie_001.webm
Just inherit the IEventMessage to the structure.
public struct YourEvent : IEventMessage{
public string Message;
}
public class YourClass : MonoBehaviour, IEventListener<YourMessage>{
void OnEnable(){
EventFlow.Register(this);
}
void OnDestroy(){
EventFlow.UnRegister(this);
}
public UniTask OnEvent(YourMessage args){
Debug.Log("Received! => " + args.Message);
}
}
EventBus.Broadcast(new YourMessage(){Message="hi"});