Custom Units: adding variables to alter Value Input

Is it possible to filter what shows in a CustomUnit’s Definition() based on variables, like you can in the Inspector?

For example:

protected override void Definition()
{
            if (myBool)
                key = ValueInput<string>("Key", "Hello");
}

So toggling a ‘myBool’ checkbox in the CustomUnit would cause the key ValueInput to show/ hide? The above code is just an example, it obviously doesn’t work, I need a checkbox to show on the Unit itself…

Any advice much appreciated!

[UnitHeaderInspectable] above a field or property to place it in the header, and [Inspectable] to show it in the graph inspector.

Anytime an Inspectable is changed, the unit will be redefined. So your code is proper, and will work as intended.

Perfect, exactly what I needed! Thank you!

Sorry to be a pain and ask about this again, I’m expanding the same concept out a bit.

Is there a way to show/ hide enums in the body of a Custom Unit based on what’s been selected further up the hierarchy?

So I have a series of enums and only show the appropriate ones based on what’s been selected, and I can have a wide network of options on a single Custom Unit?

public enum MainCategory
{
Beatles,
StarWars,
Nonsense
}

public enum Beatles
{
John,
Paul,
Ringo,
George
}

public enum StarWars
{
Vader,
Chewie
}

public enum Nonsense
{
Urgle,
Blartblart,
Sausage
}

So selecting “StarWars” from the first enum would hide the Beatles and Nonsense options?

Ideally this would be in the body of the unit, rather than in the graph inspector. They could be inspecatable in the header, but then I can’t hide them based on what is/ isn’t selected…