Пример #1
0
        public override void OnPortChanged(bool isInput)
        {
            base.OnPortChanged(isInput);

            // Function can be called on initialization from GraphView before the element is attached to a panel
            if (panel == null)
            {
                return;
            }

            NodeModel inputPortNodeModel  = m_EdgeModel?.InputPortModel?.NodeModel as NodeModel;
            NodeModel outputPortNodeModel = m_EdgeModel?.OutputPortModel?.NodeModel as NodeModel;

            PortType portType = m_EdgeModel?.OutputPortModel?.PortType ?? PortType.Data;

            if ((portType == PortType.Execution || portType == PortType.Loop) && (outputPortNodeModel != null || inputPortNodeModel != null) &&
                !string.IsNullOrEmpty(m_EdgeModel?.OutputPortModel?.Name))
            {
                m_EdgeBubble.text = m_EdgeModel.OutputPortModel.Name;
                m_EdgeBubble.EnableInClassList("candidate", (output == null || input == null));
                m_EdgeBubble.AttachTo(edgeControl, SpriteAlignment.Center);
                m_EdgeBubble.style.visibility = Visibility.Visible;
            }
            else
            {
                m_EdgeBubble.Detach();
                m_EdgeBubble.style.visibility = Visibility.Hidden;
            }
        }
Пример #2
0
        void UpdateEdgeBubble()
        {
            NodeModel inputPortNodeModel  = m_EdgeModel?.InputPortModel?.NodeModel as NodeModel;
            NodeModel outputPortNodeModel = m_EdgeModel?.OutputPortModel?.NodeModel as NodeModel;

            PortType portType = m_EdgeModel?.OutputPortModel?.PortType ?? PortType.Data;

            if ((portType == PortType.Execution || portType == PortType.Loop) && (outputPortNodeModel != null || inputPortNodeModel != null) &&
                !string.IsNullOrEmpty(m_EdgeModel?.EdgeLabel) &&
                visible)
            {
                var offset = (edgeControl as EdgeControl).BubblePosition - new Vector2(edgeControl.layout.xMin + edgeControl.layout.width / 2, edgeControl.layout.yMin + edgeControl.layout.height / 2);
                m_EdgeBubble.SetAttacherOffset(offset);
                m_EdgeBubble.text = m_EdgeModel?.EdgeLabel;
                m_EdgeBubble.EnableInClassList("candidate", (output == null || input == null));
                m_EdgeBubble.AttachTo(edgeControl, SpriteAlignment.Center);
                m_EdgeBubble.style.visibility = StyleKeyword.Null;
            }
            else
            {
                m_EdgeBubble.Detach();
                m_EdgeBubble.style.visibility = Visibility.Hidden;
            }
        }