Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public static class XFlowGraph
|
||||
{
|
||||
public static IEnumerable<IUnit> GetUnitsRecursive(this FlowGraph flowGraph, Recursion recursion)
|
||||
{
|
||||
Ensure.That(nameof(flowGraph)).IsNotNull(flowGraph);
|
||||
|
||||
if (!recursion?.TryEnter(flowGraph) ?? false)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var unit in flowGraph.units)
|
||||
{
|
||||
yield return unit;
|
||||
|
||||
var nestedGraph = (unit as SuperUnit)?.nest.graph;
|
||||
|
||||
if (nestedGraph != null)
|
||||
{
|
||||
foreach (var nestedUnit in GetUnitsRecursive(nestedGraph, recursion))
|
||||
{
|
||||
yield return nestedUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recursion?.Exit(flowGraph);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue