Unity Events Framework

Unity Events Framework

Unity Event Management / PubSub Library

Unity Event Framework is a simple and elegant way to handle events between your objects in Unity. The framework uses the PubSub pattern with current Payload states for easy access to previously sent events.

No need examples? Download now here!

Why is that necessary?

There are several advantages to this approach, ranging from reducing cohesion in your project by not directly referencing objects to resolving asynchronous events within the project. You can also retrieve the state of an event at any time if it has been previously sent.

Get Started

Installation process:

Usage

Create Payload (Event Model) for your Events:

public class TestPayload : IPayload
{
    public string Message = "";
}

To Subscribe for Payload (event) you can add listener via EventMessenger Class:

EventMessenger.Main.Subscribe<TestPayload>(payload => {
    Debug.Log(payload.Message);
});

To Publish New Payload (Event) you can:*

EventMessenger.Main.Publish(new TestPayload {
    Message = "Hello world!"
});

Also you can get latest state for any early published payload (or null if not published yet):*

TestPayload currentPayload = EventMessenger.Main.GetState<TestPayload>();
Debug.Log(currentPayload.Message);

Coming Soon (TO-DO)

I plan to add the following functionality in the near future:

  • Reactive Fields with Auto-Resolving via EventMessenger Class;

Join Community