Ejemplo n.º 1
0
        public PortInputView(PortData data)
        {
            this.AddStyleSheet("uNodeStyles/NativePortStyle");
            this.AddStyleSheet(UIElementUtility.Theme.portStyle);
            pickingMode = PickingMode.Ignore;
            ClearClassList();
            this.data = data;

            m_EdgeControl = new EdgeControl {
                from        = new Vector2(412f - 21f, 11.5f),
                to          = new Vector2(412f, 11.5f),
                edgeWidth   = 2,
                pickingMode = PickingMode.Ignore,
                visible     = false,
            };
            Add(m_EdgeControl);

            m_Container = new VisualElement {
                name = "container", visible = false
            };
            m_Container.SetOpacity(false);
            {
                if (this.data != null)
                {
                    m_Control = this.data.InstantiateControl();
                    if (m_Control != null)
                    {
                        m_Control.AddToClassList("port-control");
                        m_Container.Add(m_Control);
                    }
                }

                m_Dot = new VisualElement {
                    name = "dot"
                };
                m_Dot.style.backgroundColor = edgeColor;
                var slotElement = new VisualElement {
                    name = "slot"
                };
                {
                    slotElement.Add(m_Dot);
                }
                var slotContainer = new VisualElement()
                {
                    name = "slotContainer"
                };
                {
                    slotContainer.Add(slotElement);
                }
                m_Container.Add(slotContainer);
            }
            Add(m_Container);

            this.ScheduleAction(DoUpdate, 500);
            data?.owner?.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
        }
Ejemplo n.º 2
0
        public PortView AddPort(Orientation orientation, Direction direction, PortData portData)
        {
            PortView p = new PortView(orientation, direction, portData);

            if (string.IsNullOrEmpty(portData.portID))             //Make sure port has unique id.
            {
                portData.portID = "$" + UnityEngine.Random.Range(0, short.MaxValue).ToString();
            }
            portData.owner = this;
            portData.port  = p;
            if (p.direction == Direction.Input)
            {
                inputPorts.Add(p);
                if (orientation == Orientation.Vertical)
                {
                    flowInputContainer.Add(p);
                }
                else
                {
                    if (UIElementUtility.Theme.preferredDisplayValue == DisplayValueKind.Inside)
                    {
                        p.EnableInClassList("port-control", true);
                        p.Add(new ControlView(portData.InstantiateControl(true), true));
                    }
                    else
                    {
                        var portInputView = new PortInputView(portData);
                        portInputContainer.Add(portInputView);
                    }
                    inputContainer.Add(p);
                }
            }
            else
            {
                outputPorts.Add(p);
                if (orientation == Orientation.Vertical)
                {
                    flowOutputContainer.Add(p);
                }
                else
                {
                    outputContainer.Add(p);
                }
            }

            p.Initialize(this, portData);

            return(p);
        }
Ejemplo n.º 3
0
        public PortView AddPort(PortData portData)
        {
            PortView p = new PortView(Orientation.Horizontal, Direction.Input, portData);

            if (string.IsNullOrEmpty(portData.portID))             //Make sure port has unique id.
            {
                portData.portID = UnityEngine.Random.Range(0, short.MaxValue).ToString();
            }
            portData.owner = owner.nodeView;
            portData.port  = p;
            inputContainer.Add(p);
            portViews.Add(p);
            p.EnableInClassList("control", true);
            p.Initialize(owner.nodeView, portData);
            return(p);
        }
Ejemplo n.º 4
0
 public PortView AddOutputFlowPort(PortData portData)
 {
     portData.getPortType = () => typeof(MemberData);
     return(AddPort(Orientation.Vertical, Direction.Output, portData));
 }
Ejemplo n.º 5
0
 public PortView AddOutputValuePort(PortData portData)
 {
     return(AddPort(Orientation.Horizontal, Direction.Output, portData));
 }