Skip to content

Commit 6e51912

Browse files
committed
Fix vertical edge copy
1 parent 2a6bfd5 commit 6e51912

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,17 @@ string SerializeGraphElementsCallback(IEnumerable<GraphElement> elements)
179179
var data = new CopyPasteHelper();
180180

181181
foreach (BaseNodeView nodeView in elements.Where(e => e is BaseNodeView))
182+
{
182183
data.copiedNodes.Add(JsonSerializer.SerializeNode(nodeView.nodeTarget));
184+
foreach (var port in nodeView.nodeTarget.GetAllPorts())
185+
{
186+
if (port.portData.vertical)
187+
{
188+
foreach (var edge in port.GetEdges())
189+
data.copiedEdges.Add(JsonSerializer.Serialize(edge));
190+
}
191+
}
192+
}
183193

184194
foreach (GroupView groupView in elements.Where(e => e is GroupView))
185195
data.copiedGroups.Add(JsonSerializer.Serialize(groupView.group));

Assets/com.alelievr.NodeGraphProcessor/Runtime/Elements/BaseNode.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,29 @@ public NodePort GetPort(string fieldName, string identifier)
715715
});
716716
}
717717

718+
/// <summary>
719+
/// Return all the ports of the node
720+
/// </summary>
721+
/// <returns></returns>
722+
public IEnumerable<NodePort> GetAllPorts()
723+
{
724+
foreach (var port in inputPorts)
725+
yield return port;
726+
foreach (var port in outputPorts)
727+
yield return port;
728+
}
729+
730+
/// <summary>
731+
/// Return all the connected edges of the node
732+
/// </summary>
733+
/// <returns></returns>
734+
public IEnumerable<SerializableEdge> GetAllEdges()
735+
{
736+
foreach (var port in GetAllPorts())
737+
foreach (var edge in port.GetEdges())
738+
yield return edge;
739+
}
740+
718741
/// <summary>
719742
/// Is the port an input
720743
/// </summary>

0 commit comments

Comments
 (0)