public static void PublishEvent(this GameObject go, object e, bool ignoreIfInactive = true) { if (!ignoreIfInactive || go.activeInHierarchy) { EventSubscriber subscriber = go.GetComponent <EventSubscriber>(); if (subscriber == null) { subscriber = go.AddComponent <EventSubscriber>(); } subscriber.PublishEvent(e); } }