MonoFlux is a class that inherits MonoBehaviour but internally manages the subscription through the attributes that we include in the methods
using UniFlux;
// Inherit your class with "MonoFlux" instead of MonoBehaviour.
public sealed class TestFlux : MonoFlux
{
// Set a UniFlux's Attribute like "MethodFlux" and also set the Key, "KEY" in this case.
[MethodFlux("KEY")]
private void OnExampleMethodIsCalled() //This method will automatically subscribe!
{
Debug.Log("Hello World");
}
}
// then next you use "KEY".Dispatch(); and OnExampleMethodIsCalled from TestFlux will be called.
MonoFlux Subscribe and unsubscribe methods with attributes in the "OnEnable" or "OnDisable" events.
In Case you want to make subscriptions without attributes you might override "OnFlux" method