using System.Collections.Generic; using System.Linq; using UnityEngine; namespace Unity.VisualScripting { [UnitCategory("Graphs/Graph Nodes")] public abstract class GetGraphs : Unit where TGraph : class, IGraph, new() where TGraphAsset : Macro where TMachine : Machine { /// /// The GameObject to retrieve the graphs from. /// [DoNotSerialize] [PortLabelHidden] [NullMeansSelf] public ValueInput gameObject { get; protected set; } /// /// The graph that is set on the GameObject. /// [DoNotSerialize] [PortLabel("Graphs")] [PortLabelHidden] public ValueOutput graphList { get; protected set; } protected override void Definition() { gameObject = ValueInput(nameof(gameObject), null).NullMeansSelf(); graphList = ValueOutput(nameof(graphList), Get); } List Get(Flow flow) { var go = flow.GetValue(gameObject); return go.GetComponents() .Where(machine => go.GetComponent().nest.macro != null) .Select(machine => machine.nest.macro) .ToList(); } } }