Пример #1
0
        public static Port Create(PortDescription portDescription, IEdgeConnectorListener connectorListener)
        {
            var port = new PortView(Orientation.Horizontal,
                                    portDescription.isInputSlot ? Direction.Input : Direction.Output,
                                    portDescription.isInputSlot ? Capacity.Single : Capacity.Multi,
                                    null)
            {
                m_EdgeConnector = new EdgeConnector <Edge>(connectorListener),
            };

            port.AddManipulator(port.m_EdgeConnector);
            port.PortDescription = portDescription;
            return(port);
        }
Пример #2
0
 private void AddSlots(IEnumerable <PortDescription> slots)
 {
     foreach (var slot in slots)
     {
         var port = PortView.Create(slot, _connectorListener);
         if (slot.isOutputSlot)
         {
             outputContainer.Add(port);
         }
         else
         {
             inputContainer.Add(port);
         }
     }
 }
        private void AddEdgeFromLoad(SerializedEdge serializedEdge)
        {
            LogicNodeView sourceNodeView = _graphView.nodes.ToList().OfType <LogicNodeView>()
                                           .FirstOrDefault(x => x.NodeEditor.NodeGuid == serializedEdge.SourceNodeGuid);

            if (sourceNodeView == null)
            {
                Debug.LogWarning($"Source NodeGUID not found {serializedEdge.SourceNodeGuid}");
                return;
            }

            PortView sourceAnchor = sourceNodeView.outputContainer.Children().OfType <PortView>()
                                    .FirstOrDefault(x => x.PortDescription.MemberName == serializedEdge.SourceMemberName);

            if (sourceAnchor == null)
            {
                Debug.LogError($"Source anchor null {serializedEdge.SourceMemberName}");
                return;
            }

            LogicNodeView targetNodeView = _graphView.nodes.ToList().OfType <LogicNodeView>()
                                           .FirstOrDefault(x => x.NodeEditor.NodeGuid == serializedEdge.TargetNodeGuid);

            if (targetNodeView == null)
            {
                Debug.LogWarning($"Target NodeGUID not found {serializedEdge.TargetNodeGuid}");
                return;
            }

            PortView targetAnchor = targetNodeView.inputContainer.Children().OfType <PortView>()
                                    .FirstOrDefault(x => x.PortDescription.MemberName == serializedEdge.TargetMemberName);

            var edgeView = new Edge
            {
                userData = serializedEdge,
                output   = sourceAnchor,
                input    = targetAnchor
            };

            edgeView.output.Connect(edgeView);
            edgeView.input.Connect(edgeView);
            _graphView.AddElement(edgeView);
        }