mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Duplicating a empty selection makes linq throw exception
InvalidOperationException: Sequence contains no elements System.Linq.Enumerable.Aggregate[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`3[T1,T2,TResult] func) (at <fbb5ed17eb6e46c680000f8910ebb50c>:0)
This commit is contained in:
parent
a4ce09c212
commit
7cd3077ff0
@ -413,6 +413,7 @@ namespace XNodeEditor {
|
||||
public void DuplicateSelectedNodes() {
|
||||
// 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();
|
||||
if (selectedNodes == null || selectedNodes.Length == 0) return;
|
||||
// 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)));
|
||||
InsertDuplicateNodes(selectedNodes, topLeftNode + new Vector2(30, 30));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user