protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            foreach (var branch in unit.branches)
            {
                if (port == branch.Key || port == branch.Value)
                {
                    var index = int.Parse(port.key.PartAfter('_'));

                    var letter = ((char)('A' + index)).ToString();

                    description.label = letter;

                    if (port == branch.Key)
                    {
                        description.summary = $"Trigger to select the {letter} value.";
                    }
                    else if (port == branch.Value)
                    {
                        description.summary = $"The value to return if the {letter} control input is triggered.";
                    }
                }
            }
        }
示例#2
0
        private void OnFooterPortGUI(Rect position, IUnitPort port)
        {
            var iconPosition = new Rect
                               (
                position.x,
                position.y,
                FooterStyles.portIconSize,
                FooterStyles.portIconSize
                               );

            var descriptionWidth = position.width - FooterStyles.portIconSize - FooterStyles.spaceAfterPortIcon;

            var descriptionPosition = new Rect
                                      (
                iconPosition.xMax + FooterStyles.spaceAfterPortIcon,
                position.y,
                descriptionWidth,
                GetFooterPortDescriptionHeight(descriptionWidth, port)
                                      );

            var portDescription = PortDescription(port);

            var icon = portDescription.icon?[FooterStyles.portIconSize];

            if (icon != null)
            {
                GUI.DrawTexture(iconPosition, icon);
            }

            OnFooterPortDescriptionGUI(descriptionPosition, port);
        }
示例#3
0
        // Port Summary
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port == target.Enter)
            {
                description.summary = "Enter Flow.";
            }
            if (port == target.Exit)
            {
                description.summary = "Exit Flow.";
            }
            if (port == target.Identifier)
            {
                description.summary = "Identifier from Sent Notification";
            }
            if (port == target.Title)
            {
                description.summary = "Notification Title";
            }
            if (port == target.SubTitle)
            {
                description.summary = "Notification Sub Title";
            }
            if (port == target.Body)
            {
                description.summary = "Body Text of the Notification.";
            }
            if (port == target.Delay)
            {
                description.summary = "Delay in Seconds.";
            }
        }
        // Port Summary

        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port == target.A)
            {
                description.summary   = "Start Value.";
                description.showLabel = true;
            }
            else if (port == target.B)
            {
                description.summary   = "End Value.";
                description.showLabel = true;
            }
            else if (port == target.ResultValue)
            {
                description.summary   = "Tweened Value.";
                description.showLabel = false;
                description.label     = "Tweened Value.";
            }

            else if (port == target.duration)
            {
                description.summary   = "Duration of Tween in seconds.";
                description.showLabel = true;
            }

            else if (port == target.start)
            {
                description.summary   = "Start Tween.";
                description.showLabel = false;
            }

            else if (port == target.started)
            {
                description.summary   = "Event fired when Tween starts.";
                description.showLabel = true;
            }

            else if (port == target.tick)
            {
                description.summary   = "Connect this to the value you want to Tween.";
                description.showLabel = true;
            }

            else if (port == target.completed)
            {
                description.summary   = "Event fired when Tweening is completed";
                description.showLabel = true;
                description.label     = "Done";
            }

            else if (port == target.DopeEasingTypeValue)
            {
                description.summary   = "The Type of Easing Value to be applied to the tween.";
                description.showLabel = false;
                description.label     = "Easing Type";
            }
        }
示例#5
0
        public UnitPortDescriptor(IUnitPort target)
        {
            Ensure.That(nameof(target)).IsNotNull(target);

            this.target = target;

            description.portType = target;
        }
示例#6
0
        private bool CanConnectTo(IUnitPort port)
        {
            Ensure.That(nameof(port)).IsNotNull(port);

            return(unit != null &&                 // We belong to a unit
                   port.unit != null &&            // Port belongs to a unit
                   port.unit != unit &&            // that is different than the current one
                   port.unit.graph == unit.graph); // but is on the same graph.
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port is ControlInput && unit.awaitedInputs.Contains((ControlInput)port))
            {
                description.showLabel = false;
            }
        }
示例#8
0
        protected virtual void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            var reflectedPortDescription = ReflectedPortDescription(port);

            if (reflectedPortDescription != null)
            {
                description.CopyFrom(reflectedPortDescription);
            }
        }
示例#9
0
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port == unit.value)
            {
                description.summary = unit.member.info.Summary();
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (unit.dictionary && port == unit.currentItem)
            {
                description.label   = "Value";
                description.summary = "The value of the current item of the loop.";
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port is ValueOutput && unit.members.TryGetValue((ValueOutput)port, out Member member))
            {
                description.label   = member.info.HumanName();
                description.summary = member.info.Summary();
            }
        }
示例#12
0
        public void DescribePort(IUnitPort port, UnitPortDescription description)
        {
            description.getMetadata = (unitMetadata) => unitMetadata.StaticObject(port);

            // Only defined units can have specific ports
            if (state == State.Defined)
            {
                DefinedPort(port, description);
            }
        }
示例#13
0
        public override Inspector GetPortInspector(IUnitPort port, Metadata metadata)
        {
            if (port == unit.InputAction)
            {
                InspectorProvider.instance.Renew(ref nameInspector, metadata, inputActionInspectorConstructor);
                return(nameInspector);
            }

            return(base.GetPortInspector(port, metadata));
        }
示例#14
0
        public void AddPortData(PropertyInfo pi, IUnitPort unitPort)
        {
            PortData pd = new PortData()
            {
                memberInfo = pi,
                unitPort   = unitPort
            };

            portDatas.Add(pd);
        }
示例#15
0
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            var index = unit.argumentPorts.IndexOf(port as ValueOutput);

            if (index >= 0)
            {
                description.label = "Arg. " + index;
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            var documentation = member.info.Documentation();

            if (port == unit.enter)
            {
                description.label   = "Invoke";
                description.summary = "The entry point to invoke the method.";

                if (member.isGettable)
                {
                    description.summary += " You can still get the return value without connecting this port.";
                }
            }
            else if (port == unit.exit)
            {
                description.summary = "The action to call once the method has been invoked.";
            }
            else if (port == unit.result)
            {
                if (member.isGettable)
                {
                    description.summary = documentation?.returns;
                }

                if (unit.supportsChaining && unit.chainable)
                {
                    description.showLabel = true;
                }
            }
            else if (port == unit.targetOutput)
            {
                if (member.isGettable)
                {
                    description.showLabel = true;
                }
            }
            else if (port is ValueInput && unit.inputParameters.ContainsValue((ValueInput)port))
            {
                var parameter = member.GetParameterInfos().Single(p => "%" + p.Name == port.key);

                description.label   = parameter.DisplayName();
                description.summary = documentation?.ParameterSummary(parameter);
            }
            else if (port is ValueOutput && unit.outputParameters.ContainsValue((ValueOutput)port))
            {
                var parameter = member.GetParameterInfos().Single(p => "&" + p.Name == port.key);

                description.label   = parameter.DisplayName();
                description.summary = documentation?.ParameterSummary(parameter);
            }
        }
示例#17
0
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

#if !VISUAL_SCRIPTING_1_7_3
            if (port == unit.target)
            {
                description.icon = PathUtil.Load("EditorWindow", CommunityEditorPath.Fundamentals);
            }
#endif
        }
示例#18
0
        public void InvalidlyConnectTo(IUnitPort port)
        {
            Ensure.That(nameof(port)).IsNotNull(port);

            if (!(port is TInvalidOther))
            {
                throw new InvalidConnectionException();
            }

            ConnectToInvalid((TInvalidOther)port);
        }
        public override Inspector GetPortInspector(IUnitPort port, Metadata metadata)
        {
            if (port == unit.name)
            {
                // This feels so hacky. The real holy grail here would be to support attribute decorators like Unity does.
                InspectorProvider.instance.Renew(ref nameInspector, metadata, nameInspectorConstructor);

                return(nameInspector);
            }

            return(base.GetPortInspector(port, metadata));
        }
示例#20
0
        public UnitRelation(IUnitPort source, IUnitPort destination)
        {
            Ensure.That(nameof(source)).IsNotNull(source);
            Ensure.That(nameof(destination)).IsNotNull(destination);

            if (source.unit != destination.unit)
            {
                throw new NotSupportedException("Cannot create relations across units.");
            }

            this.source      = source;
            this.destination = destination;
        }
示例#21
0
        private void CompleteContextualConnection(IUnitPort source, IUnitPort destination)
        {
            source.ValidlyConnectTo(destination);
            Cache();
            var unitPosition = this.Widget <IUnitWidget>(destination.unit).position.position;
            var portPosition = this.Widget <IUnitPortWidget>(destination).handlePosition.center.PixelPerfect();
            var offset       = portPosition - unitPosition;

            destination.unit.position -= offset;
            this.Widget(destination.unit).Reposition();
            connectionSource = null;
            GUI.changed      = true;
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port is ValueInput)
            {
                var index = unit.multiInputs.IndexOf((ValueInput)port);

                if (index >= 0)
                {
                    description.label = ((char)('A' + index)).ToString();
                }
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port is ControlOutput)
            {
                var index = unit.multiOutputs.IndexOf((ControlOutput)port);

                if (index >= 0)
                {
                    description.label = index.ToString();
                }
            }
        }
示例#24
0
        private void OnPortGUI(Rect portPosition, IUnitPort port)
        {
            var portDescription = port.Description <UnitPortDescription>();

            var labelWidth = portPosition.width - Styles.portIcon.fixedWidth - Styles.portIcon.margin.right;

            var iconPosition = new Rect
                               (
                portPosition.x,
                portPosition.y,
                Styles.portIcon.fixedWidth,
                Styles.portIcon.fixedHeight
                               );

            var icon = portDescription.icon?[IconSize.Small];

            if (icon != null)
            {
                GUI.DrawTexture(iconPosition, icon);
            }

            var labelContent = GetLabelContent(port);

            var labelPosition = new Rect
                                (
                iconPosition.xMax + Styles.portIcon.margin.right,
                portPosition.y,
                labelWidth,
                Styles.portLabel.CalcHeight(labelContent, labelWidth)
                                );

            GUI.Label(labelPosition, labelContent, Styles.portLabel);

            var summary = portDescription.summary;

            if (!StringUtility.IsNullOrWhiteSpace(summary))
            {
                var descriptionContent = new GUIContent(summary);

                var descriptionPosition = new Rect
                                          (
                    labelPosition.x,
                    labelPosition.yMax,
                    labelWidth,
                    Styles.portDescription.CalcHeight(descriptionContent, labelWidth)
                                          );

                GUI.Label(descriptionPosition, descriptionContent, Styles.portDescription);
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            foreach (var branch in unit.branches)
            {
                if (branch.Value == port)
                {
                    var enumValue = branch.Key;
                    description.label   = enumValue.DisplayName();
                    description.summary = $"The action to execute if the enum has the value '{enumValue}'.";
                }
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            foreach (var branch in unit.branches)
            {
                if (branch.Value == port)
                {
                    var option = branch.Key;

                    description.label   = GetLabelForOption(option);
                    description.summary = $"The action to execute if the selector has the value {GetLabelForOption(option)}.";
                }
            }
        }
示例#27
0
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port == unit.Target)
            {
                description.summary =
                    "A player input component used to list available actions and find the referenced InputAction";
            }
            if (port == unit.InputAction)
            {
                description.summary =
                    "An input action, either from the linked player input component or directly connected";
            }
        }
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            for (int i = 0; i < ((CreateBinarySave)target).count; i++)
            {
                if (port.key == "name_" + i.ToString())
                {
                    description.showLabel = false;
                }
                if (port.key == "value_" + i.ToString())
                {
                    description.label = "Value";
                }
            }
        }
        // Port Summary
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            if (port == target.enter)
            {
                description.summary = "Enter Flow.";
            }
            if (port == target.exit)
            {
                description.summary = "Exit Flow.";
            }
            if (port == target.Identifier)
            {
                description.summary = "Identifier from Sent Notification";
            }
        }
示例#30
0
        protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
        {
            base.DefinedPort(port, description);

            var definition = unit.graph.validPortDefinitions.OfType <IUnitInputPortDefinition>().SingleOrDefault(d => d.key == port.key);

            if (definition != null)
            {
                description.label   = definition.Label();
                description.summary = definition.summary;

                if (definition.hideLabel)
                {
                    description.showLabel = false;
                }
            }
        }