Change var visibility in inspector based on initial choices?

Let’s say I have my first variable, a boolean named ‘isBox’.

If isBox is true, another var that allows you to set it’s size appears below.
If not, some other option appears.

How does one go about doing that?

I thought maybe I could do:

if (optionHidden){
     @HideInInspector
     var myVar = something;
}

But that doesn’t work.

Can hidden status be toggled?

You can’t change an item’s visibility like that, but you can make a custom inspector panel using the Editor API.

That’s what I was afraid of. I’m not quite ready to tackle custom editors yet!

I’ll just split the functionality into two scripts for now.