Exemplo n.º 1
0
        public void Initialize(InvokableCallList invokableList, UnityEventBaseEx unityEventBase)
        {
            foreach (var persistentCall in m_Calls)
            {
                if (!persistentCall.IsValid())
                {
                    continue;
                }

                var call = persistentCall.GetRuntimeCall(unityEventBase);
                if (call != null)
                {
                    invokableList.AddPersistentInvokableCall(call);
                }
            }
        }
Exemplo n.º 2
0
        public virtual BaseInvokableCall GetRuntimeCall(UnityEventBaseEx 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);
            }

            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);
        }
Exemplo n.º 3
0
        public override BaseInvokableCall GetRuntimeCall(UnityEventBaseEx 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);
            }

            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:
            {
                var type = m_Arguments.GetSerializedDataType();
                if (type == typeof(Color))
                {
                    return(new CachedInvokableCall <Color>(targetObject, method, m_Arguments.colorArgument));
                }
                if (type == typeof(Color32))
                {
                    return(new CachedInvokableCall <Color32>(targetObject, method, m_Arguments.colorArgument));
                }
                if (type != typeof(string))
                {
                    return(new UnknownCachedInvokableCall(target, method, m_Arguments.serializedDataArgument));
                }
                else
                {
                    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);
        }