Skip to content

Instantly share code, notes, and snippets.

@Sov3rain
Created January 1, 2024 19:56
Show Gist options
  • Save Sov3rain/99296ba2c86989700a94ccc8aaf200c7 to your computer and use it in GitHub Desktop.
Save Sov3rain/99296ba2c86989700a94ccc8aaf200c7 to your computer and use it in GitHub Desktop.
Simple 0 dependency Event Bus for Unity C#
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