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:
commit
a825af8192
@ -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));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user