コード例 #1
0
    public static void Subscribe(GameEvent gameEvent, Object subscriber, Action action)
    {
        if (subscriber == null || action == null || Instance == null)
        {
            return;
        }

        var eventSubscribersPair = Instance._eventSubscribersPairs.FirstOrDefault(p => p.Event == gameEvent);

        if (eventSubscribersPair != null)
        {
            eventSubscribersPair.AddSubscriberActionPair(subscriber, action);
        }
        else
        {
            Instance.AddEventSubscribersPair(gameEvent, subscriber, action);
        }
    }