public void OnDropOutsidePort(Edge edge, Vector2 position)
        {
            var draggedPort = (edge.output != null ? edge.output.edgeConnector.edgeDragHelper.draggedPort : null) ?? (edge.input != null ? edge.input.edgeConnector.edgeDragHelper.draggedPort : null);

            m_SearchWindowProvider.connectedPort = (ShaderPort)draggedPort;
            SearchWindow.Open(new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), m_SearchWindowProvider);
        }
示例#2
0
 private void GetSlots(Edge edge, out LogicSlot leftLogicSlot,
                       out LogicSlot rightLogicSlot)
 {
     leftLogicSlot  = (edge.output as LogicPort).Description;
     rightLogicSlot = (edge.input as LogicPort).Description;
     if (leftLogicSlot == null || rightLogicSlot == null)
     {
         Debug.Log("an edge is null");
     }
 }
 private void GetSlots(Edge edge, out PortDescription leftPortDescription,
                       out PortDescription rightPortDescription)
 {
     leftPortDescription  = (edge.output as PortView).PortDescription;
     rightPortDescription = (edge.input as PortView).PortDescription;
     if (leftPortDescription == null || rightPortDescription == null)
     {
         Debug.Log("an edge is null");
     }
 }
        public void OnDrop(GraphView graphView, Edge edge)
        {
            var leftSlot  = edge.output.GetSlot();
            var rightSlot = edge.input.GetSlot();

            if (leftSlot != null && rightSlot != null)
            {
                m_Graph.owner.RegisterCompleteObjectUndo("Connect Edge");
                m_Graph.Connect(leftSlot.slotReference, rightSlot.slotReference);
            }
        }
示例#5
0
        public bool AddEdgeFromLoad(SerializedEdge serializedEdge)
        {
            LogicNodeView sourceNodeView = _graphView.nodes.ToList().OfType <LogicNodeView>()
                                           .FirstOrDefault(x => x.LogicNodeEditor.NodeGuid == serializedEdge.SourceNodeGuid);

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

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

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

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

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

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

            if (targetAnchor == null)
            {
                Debug.LogError($"Target anchor null {serializedEdge.SourceMemberName} {serializedEdge.TargetNodeGuid}");
                return(false);
            }

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

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

            return(true);
        }
示例#6
0
        GEdge AddEdge(IEdge edge)
        {
            var sourceNode = m_Graph.GetNodeFromGuid(edge.outputSlot.nodeGuid);

            if (sourceNode == null)
            {
                Debug.LogWarning("Source node is null");
                return(null);
            }
            var sourceSlot = sourceNode.FindOutputSlot <NodeSlot>(edge.outputSlot.slotId);

            var targetNode = m_Graph.GetNodeFromGuid(edge.inputSlot.nodeGuid);

            if (targetNode == null)
            {
                Debug.LogWarning("Target node is null");
                return(null);
            }
            var targetSlot = targetNode.FindInputSlot <NodeSlot>(edge.inputSlot.slotId);

            var sourceNodeView = m_GraphView.nodes.ToList().OfType <NodeView>().FirstOrDefault(x => x.node == sourceNode);

            if (sourceNodeView != null)
            {
                var sourceAnchor = sourceNodeView.outputContainer.Children().OfType <NodePort>().FirstOrDefault(x => x.slot.Equals(sourceSlot));

                var targetNodeView = m_GraphView.nodes.ToList().OfType <NodeView>().FirstOrDefault(x => x.node == targetNode);
                var targetAnchor   = targetNodeView.inputContainer.Children().OfType <NodePort>().FirstOrDefault(x => x.slot.Equals(targetSlot));

                var edgeView = new GEdge
                {
                    userData = edge,
                    output   = sourceAnchor,
                    input    = targetAnchor
                };

                edgeView.output.Connect(edgeView);
                edgeView.input.Connect(edgeView);
                m_GraphView.AddElement(edgeView);
                sourceNodeView.RefreshPorts();
                targetNodeView.RefreshPorts();
                sourceNodeView.UpdatePortInputTypes();
                targetNodeView.UpdatePortInputTypes();

                return(edgeView);
            }

            return(null);
        }
示例#7
0
        public void AddEdge(Edge edgeView)
        {
            LogicSlot leftLogicSlot;
            LogicSlot rightLogicSlot;

            GetSlots(edgeView, out leftLogicSlot, out rightLogicSlot);

            _logicGraphEditorObject.RegisterCompleteObjectUndo("Connect Edge");
            SerializedEdge serializedEdge = new SerializedEdge
            {
                SourceNodeGuid   = leftLogicSlot.Owner.NodeGuid,
                SourceMemberName = leftLogicSlot.MemberName,
                TargetNodeGuid   = rightLogicSlot.Owner.NodeGuid,
                TargetMemberName = rightLogicSlot.MemberName
            };

            _logicGraphEditorObject.LogicGraphData.SerializedEdges.Add(serializedEdge);

            edgeView.userData = serializedEdge;
            edgeView.output.Connect(edgeView);
            edgeView.input.Connect(edgeView);
            _graphView.AddElement(edgeView);
        }
示例#8
0
 public void OnDropOutsidePort(Edge edge, Vector2 position)
 {
 }
 public void OnDrop(GraphView graphView, Edge edge)
 {
     _logicGraphEditorView.AddEdge(edge);
 }