Skip to content

shlifedev/event-flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

20104dd · Feb 22, 2025

History

34 Commits
Feb 22, 2025
Feb 21, 2025
Feb 21, 2025
May 16, 2024
Nov 5, 2024
Jan 27, 2025
May 16, 2024

Repository files navigation

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