1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-02-08 08:14:54 +08:00

Merge pull request #203 from nostek/fix/duplicateemptyselection

Duplicating a empty selection makes linq throw exception
This commit is contained in:
Thor Brigsted 2019-11-05 10:55:28 +01:00 committed by GitHub
commit a825af8192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -413,6 +413,7 @@ namespace XNodeEditor {
public void DuplicateSelectedNodes() { public void DuplicateSelectedNodes() {
// Get selected nodes which are part of this graph // Get selected nodes which are part of this graph
XNode.Node[] selectedNodes = Selection.objects.Select(x => x as XNode.Node).Where(x => x != null && x.graph == graph).ToArray(); XNode.Node[] selectedNodes = Selection.objects.Select(x => x as XNode.Node).Where(x => x != null && x.graph == graph).ToArray();
if (selectedNodes == null || selectedNodes.Length == 0) return;
// Get top left node position // Get top left node position
Vector2 topLeftNode = selectedNodes.Select(x => x.position).Aggregate((x, y) => new Vector2(Mathf.Min(x.x, y.x), Mathf.Min(x.y, y.y))); Vector2 topLeftNode = selectedNodes.Select(x => x.position).Aggregate((x, y) => new Vector2(Mathf.Min(x.x, y.x), Mathf.Min(x.y, y.y)));
InsertDuplicateNodes(selectedNodes, topLeftNode + new Vector2(30, 30)); InsertDuplicateNodes(selectedNodes, topLeftNode + new Vector2(30, 30));