Created
January 1, 2024 19:56
-
-
Save Sov3rain/99296ba2c86989700a94ccc8aaf200c7 to your computer and use it in GitHub Desktop.
Simple 0 dependency Event Bus for Unity C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public static class EventManager<T> | |
{ | |
private static event Action<T> Event; | |
public static void AddListener(Action<T> handler) => Event += handler; | |
public static void RemoveListener(Action<T> handler) => Event -= handler; | |
public static void RemoveAllListeners() => Event = null; | |
public static void Invoke(T arg) => Event?.Invoke(arg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment