Ejemplo n.º 1
0
        public void RegisterMethod(MethodInfo method, object target = null)
        {
            var invoker = MessageInvoker.Create(method, target);

#if UNITY_EDITOR
            if (items.ContainsKey(invoker.MessageType))
            {
                UnityEngine.Debug.LogError(string.Format("消息类型重复: {0}", invoker.MessageType));
            }
#endif
            items.Add(invoker.MessageType, invoker);
        }
Ejemplo n.º 2
0
        public bool RegisterMethod(MethodInfo method, object target = null)
        {
#if UNITY_EDITOR && !GX_UNITTEST
            if (IsValid(method) == false)
            {
                UnityEngine.Debug.LogWarning(string.Format("无法兼容的函数签名: {0}", method));
            }
#endif
            var invoker = MessageInvoker.Create(method, target);
#if UNITY_EDITOR
            if (items.ContainsKey(invoker.MessageType))
            {
                UnityEngine.Debug.LogWarning(string.Format("消息类型重复注册并覆盖: {0}", invoker.MessageType));
            }
#endif
            items[invoker.MessageType] = invoker;
            return(true);
        }
Ejemplo n.º 3
0
    public bool RegisterMethod(MethodInfo method, object target = null)
    {
        var invoker = MessageInvoker.Create(method, target);

        if (invoker == null)
        {
            return(false);
        }
#if UNITY_EDITOR
        if (items.ContainsKey(invoker.NetMessageType))
        {
            UnityEngine.Debug.LogError(string.Format("消息类型重复: {0}", invoker.NetMessageType));
        }
#endif
        try
        {
            items.Add(invoker.NetMessageType, invoker);
        }
        catch (System.Exception e)
        {
            Engine.Utility.Log.Error("{0}:{1}", invoker.NetMessageType.ToString(), e.ToString());
        }
        return(true);
    }