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.

GetGraphs.cs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using UnityEngine;
  4. namespace Unity.VisualScripting
  5. {
  6. [UnitCategory("Graphs/Graph Nodes")]
  7. public abstract class GetGraphs<TGraph, TGraphAsset, TMachine> : Unit
  8. where TGraph : class, IGraph, new()
  9. where TGraphAsset : Macro<TGraph>
  10. where TMachine : Machine<TGraph, TGraphAsset>
  11. {
  12. /// <summary>
  13. /// The GameObject to retrieve the graphs from.
  14. /// </summary>
  15. [DoNotSerialize]
  16. [PortLabelHidden]
  17. [NullMeansSelf]
  18. public ValueInput gameObject { get; protected set; }
  19. /// <summary>
  20. /// The graph that is set on the GameObject.
  21. /// </summary>
  22. [DoNotSerialize]
  23. [PortLabel("Graphs")]
  24. [PortLabelHidden]
  25. public ValueOutput graphList { get; protected set; }
  26. protected override void Definition()
  27. {
  28. gameObject = ValueInput<GameObject>(nameof(gameObject), null).NullMeansSelf();
  29. graphList = ValueOutput(nameof(graphList), Get);
  30. }
  31. List<TGraphAsset> Get(Flow flow)
  32. {
  33. var go = flow.GetValue<GameObject>(gameObject);
  34. return go.GetComponents<TMachine>()
  35. .Where(machine => go.GetComponent<TMachine>().nest.macro != null)
  36. .Select(machine => machine.nest.macro)
  37. .ToList();
  38. }
  39. }
  40. }