Пример #1
0
        public BaseInvokableCall GetRuntimeCall(UnityEventBase theEvent)
        {
            BaseInvokableCall result;

            if (this.m_CallState == UnityEventCallState.RuntimeOnly && !Application.isPlaying)
            {
                result = null;
            }
            else if (this.m_CallState == UnityEventCallState.Off || theEvent == null)
            {
                result = null;
            }
            else
            {
                MethodInfo methodInfo = theEvent.FindMethod(this);
                if (methodInfo == null)
                {
                    result = null;
                }
                else
                {
                    switch (this.m_Mode)
                    {
                    case PersistentListenerMode.EventDefined:
                        result = theEvent.GetDelegate(this.target, methodInfo);
                        break;

                    case PersistentListenerMode.Void:
                        result = new InvokableCall(this.target, methodInfo);
                        break;

                    case PersistentListenerMode.Object:
                        result = PersistentCall.GetObjectCall(this.target, methodInfo, this.m_Arguments);
                        break;

                    case PersistentListenerMode.Int:
                        result = new CachedInvokableCall <int>(this.target, methodInfo, this.m_Arguments.intArgument);
                        break;

                    case PersistentListenerMode.Float:
                        result = new CachedInvokableCall <float>(this.target, methodInfo, this.m_Arguments.floatArgument);
                        break;

                    case PersistentListenerMode.String:
                        result = new CachedInvokableCall <string>(this.target, methodInfo, this.m_Arguments.stringArgument);
                        break;

                    case PersistentListenerMode.Bool:
                        result = new CachedInvokableCall <bool>(this.target, methodInfo, this.m_Arguments.boolArgument);
                        break;

                    default:
                        result = null;
                        break;
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public BaseInvokableCall GetRuntimeCall(UnityEventBase theEvent)
        {
            if (m_CallState == UnityEventCallState.RuntimeOnly && !Application.isPlaying)
            {
                return(null);
            }
            if (m_CallState == UnityEventCallState.Off || theEvent == null)
            {
                return(null);
            }

            var method = theEvent.FindMethod(this);

            if (method == null)
            {
                return(null);
            }

            if (!method.IsStatic && target == null)
            {
                return(null);
            }

            var targetObject = method.IsStatic ? null : target;

            switch (m_Mode)
            {
            case PersistentListenerMode.EventDefined:
                return(theEvent.GetDelegate(targetObject, method));

            case PersistentListenerMode.Object:
                return(GetObjectCall(targetObject, method, m_Arguments));

            case PersistentListenerMode.Float:
                return(new CachedInvokableCall <float>(targetObject, method, m_Arguments.floatArgument));

            case PersistentListenerMode.Int:
                return(new CachedInvokableCall <int>(targetObject, method, m_Arguments.intArgument));

            case PersistentListenerMode.String:
                return(new CachedInvokableCall <string>(targetObject, method, m_Arguments.stringArgument));

            case PersistentListenerMode.Bool:
                return(new CachedInvokableCall <bool>(targetObject, method, m_Arguments.boolArgument));

            case PersistentListenerMode.Void:
                return(new InvokableCall(targetObject, method));
            }
            return(null);
        }
Пример #3
0
        public BaseInvokableCall GetRuntimeCall(UnityEventBase theEvent)
        {
            if (this.m_CallState == UnityEventCallState.RuntimeOnly && !Application.isPlaying)
            {
                return((BaseInvokableCall)null);
            }
            if (this.m_CallState == UnityEventCallState.Off || theEvent == null)
            {
                return((BaseInvokableCall)null);
            }
            MethodInfo method = theEvent.FindMethod(this);

            if (method == null)
            {
                return((BaseInvokableCall)null);
            }
            switch (this.m_Mode)
            {
            case PersistentListenerMode.EventDefined:
                return(theEvent.GetDelegate((object)this.target, method));

            case PersistentListenerMode.Void:
                return((BaseInvokableCall) new InvokableCall((object)this.target, method));

            case PersistentListenerMode.Object:
                return(PersistentCall.GetObjectCall(this.target, method, this.m_Arguments));

            case PersistentListenerMode.Int:
                return((BaseInvokableCall) new CachedInvokableCall <int>(this.target, method, this.m_Arguments.intArgument));

            case PersistentListenerMode.Float:
                return((BaseInvokableCall) new CachedInvokableCall <float>(this.target, method, this.m_Arguments.floatArgument));

            case PersistentListenerMode.String:
                return((BaseInvokableCall) new CachedInvokableCall <string>(this.target, method, this.m_Arguments.stringArgument));

            case PersistentListenerMode.Bool:
                return((BaseInvokableCall) new CachedInvokableCall <bool>(this.target, method, this.m_Arguments.boolArgument));

            default:
                return((BaseInvokableCall)null);
            }
        }
Пример #4
0
        public BaseInvokableCall GetRuntimeCall(UnityEventBase theEvent)
        {
            if (m_CallState == UnityEventCallState.Off || theEvent == null)
            {
                return(null);
            }
            MethodInfo methodInfo = theEvent.FindMethod(this);

            if (methodInfo == null)
            {
                return(null);
            }
            switch (m_Mode)
            {
            case PersistentListenerMode.EventDefined:
                return(theEvent.GetDelegate(target, methodInfo));

            case PersistentListenerMode.Object:
                return(GetObjectCall(target, methodInfo, m_Arguments));

            case PersistentListenerMode.Float:
                return(new CachedInvokableCall <float>(target, methodInfo, m_Arguments.floatArgument));

            case PersistentListenerMode.Int:
                return(new CachedInvokableCall <int>(target, methodInfo, m_Arguments.intArgument));

            case PersistentListenerMode.String:
                return(new CachedInvokableCall <string>(target, methodInfo, m_Arguments.stringArgument));

            case PersistentListenerMode.Bool:
                return(new CachedInvokableCall <bool>(target, methodInfo, m_Arguments.boolArgument));

            case PersistentListenerMode.Void:
                return(new InvokableCall(target, methodInfo));

            default:
                return(null);
            }
        }
Пример #5
0
        public BaseInvokableCall GetRuntimeCall(UnityEventBase theEvent)
        {
            if ((this.m_CallState != UnityEventCallState.RuntimeOnly) || Application.isPlaying)
            {
                if ((this.m_CallState == UnityEventCallState.Off) || (theEvent == null))
                {
                    return(null);
                }
                MethodInfo theFunction = theEvent.FindMethod(this);
                if (theFunction == null)
                {
                    return(null);
                }
                switch (this.m_Mode)
                {
                case PersistentListenerMode.EventDefined:
                    return(theEvent.GetDelegate(this.target, theFunction));

                case PersistentListenerMode.Void:
                    return(new InvokableCall(this.target, theFunction));

                case PersistentListenerMode.Object:
                    return(GetObjectCall(this.target, theFunction, this.m_Arguments));

                case PersistentListenerMode.Int:
                    return(new CachedInvokableCall <int>(this.target, theFunction, this.m_Arguments.intArgument));

                case PersistentListenerMode.Float:
                    return(new CachedInvokableCall <float>(this.target, theFunction, this.m_Arguments.floatArgument));

                case PersistentListenerMode.String:
                    return(new CachedInvokableCall <string>(this.target, theFunction, this.m_Arguments.stringArgument));

                case PersistentListenerMode.Bool:
                    return(new CachedInvokableCall <bool>(this.target, theFunction, this.m_Arguments.boolArgument));
                }
            }
            return(null);
        }