Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.42 KB

README.md

File metadata and controls

52 lines (35 loc) · 1.42 KB

EventFlow

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)

Requirement

  • UniTask
Movie_001.webm

How to use

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"});