protected override void RegisterPorts()
        {
            if (field == null)
            {
                return;
            }

            if (reflectedEvent == null)
            {
                reflectedEvent = new ReflectedUnityEvent(field.FieldType);
            }

            if (!field.IsStatic)
            {
                instancePort = AddValueInput(field.RTReflectedType().FriendlyName(), field.RTReflectedType(), "Instance");
            }

            args = new object[reflectedEvent.parameters.Length];
            for (var _i = 0; _i < reflectedEvent.parameters.Length; _i++)
            {
                var i         = _i;
                var parameter = reflectedEvent.parameters[i];
                AddValueOutput(parameter.Name, "arg" + i, parameter.ParameterType, () => { return(args[i]); });
            }

            callback = AddFlowOutput(field.Name, "Event");
        }
Пример #2
0
        protected override void RegisterPorts()
        {
            eventType  = eventType != null? eventType : typeof(UnityEventBase);
            eventInput = AddValueInput("Event", eventType);
            if (eventType == typeof(UnityEventBase))
            {
                return;
            }

            if (reflectedEvent == null)
            {
                reflectedEvent = new ReflectedUnityEvent(eventType);
            }
            if (reflectedEvent.eventType != eventType)
            {
                reflectedEvent.InitForEventType(eventType);
            }

            argValues = new object[reflectedEvent.parameters.Length];
            for (var _i = 0; _i < reflectedEvent.parameters.Length; _i++)
            {
                var i         = _i;
                var parameter = reflectedEvent.parameters[i];
                AddValueOutput(parameter.Name, "arg" + i, parameter.ParameterType, () => { return(argValues[i]); });
            }

            callback = AddFlowOutput("Callback");
            if (!autoHandleRegistration)
            {
                AddFlowInput("Register", Register, "Add");
                AddFlowInput("Unregister", Unregister, "Remove");
            }
        }