No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XFlowGraph.cs 912B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections.Generic;
  2. namespace Unity.VisualScripting
  3. {
  4. public static class XFlowGraph
  5. {
  6. public static IEnumerable<IUnit> GetUnitsRecursive(this FlowGraph flowGraph, Recursion recursion)
  7. {
  8. Ensure.That(nameof(flowGraph)).IsNotNull(flowGraph);
  9. if (!recursion?.TryEnter(flowGraph) ?? false)
  10. {
  11. yield break;
  12. }
  13. foreach (var unit in flowGraph.units)
  14. {
  15. yield return unit;
  16. var nestedGraph = (unit as SubgraphUnit)?.nest.graph;
  17. if (nestedGraph != null)
  18. {
  19. foreach (var nestedUnit in GetUnitsRecursive(nestedGraph, recursion))
  20. {
  21. yield return nestedUnit;
  22. }
  23. }
  24. }
  25. recursion?.Exit(flowGraph);
  26. }
  27. }
  28. }