コード例 #1
0
 /// <summary>
 /// Unsubscribes a callback from an event
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="type"></param>
 public static void UnsubscribeFromEvent(EventDataCallback callback, EventType type)
 {
     if (eventsData.ContainsKey(type))
     {
         eventsData[type] = Delegate.RemoveAll(eventsData[type], callback);
     }
 }
コード例 #2
0
    public static void UnsubscribeFromEvent(EventDataCallback callback, Component component, EventType type)
    {
        CallbackComponentPair pair = new CallbackComponentPair(callback, component);

        if (componentEventsData.ContainsKey(type))
        {
            componentEventsData[type].Unsubscribe(pair);
        }
    }
コード例 #3
0
    /// <summary>
    /// Subscribe to an event with a callback. This removes all previous subscriptions for this event.
    /// </summary>
    /// <param name="callback"></param>
    /// <param name="type"></param>
    public static void OverrideSubscription(EventDataCallback callback, Component component, EventType type)
    {
        CallbackComponentPair pair = new CallbackComponentPair(callback, component);

        ComponentEventsContainer cont = new ComponentEventsContainer();

        cont.AddPair(pair);
        componentEventsData.Add(type, cont);
    }
コード例 #4
0
ファイル: GameClientPeer.cs プロジェクト: TinyUlt/TinyPhoton
 public void RegisterEventCode(EventCode code, EventDataCallback callback)
 {
     if (EventDataContain.ContainsKey(code))
     {
         EventDataContain[code] += callback;
     }
     else
     {
         EventDataContain[code] = callback;
     }
 }
コード例 #5
0
    /// <summary>
    /// Subscribe to an event with a callback from a component. The subscription is removed automatically when the component is destroyed.
    /// </summary>
    /// <param name="callback"></param>
    /// <param name="component"></param>
    /// <param name="type"></param>
    public static void SubscribeToEvent(EventDataCallback callback, Component component, EventType type)
    {
        CallbackComponentPair pair = new CallbackComponentPair(callback, component);

        if (!componentEventsData.ContainsKey(type))
        {
            ComponentEventsContainer cont = new ComponentEventsContainer();
            cont.AddPair(pair);
            componentEventsData.Add(type, cont);
        }
        else
        {
            componentEventsData[type].AddPair(pair);
        }
    }
コード例 #6
0
ファイル: GameClientPeer.cs プロジェクト: TinyUlt/TinyPhoton
    public void UnRegisterEventCode(EventCode code, EventDataCallback callback)
    {
        if (EventDataContain.ContainsKey(code))
        {
            EventDataContain[code] -= callback;

            if (EventDataContain[code] == null)
            {
                EventDataContain.Remove(code);
            }
        }
        else
        {
            Debug.LogWarning("未注册事件:" + code.ToString());
        }
    }
コード例 #7
0
 /// <summary>
 /// Subscribe to an event with a callback. This removes all previous subscriptions for this event.
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="type"></param>
 public static void OverrideSubscription(EventDataCallback callback, EventType type)
 {
     SetValueDelegateDictionary(eventsData, type, callback);
 }
コード例 #8
0
 /// <summary>
 /// Subscribe to an event with a callback
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="type"></param>
 public static void SubscribeToEvent(EventDataCallback callback, EventType type)
 {
     AddToDelegateDictionary <EventType>(eventsData, type, callback);
 }