C# how to make collapsible variables?

So for the game I am creating I need a lot of variables. I want to know if there is a way to put these variables in a collapsible menu within the inspector. Can anyone help me out?

Here’s just a few variables for you to work with. Thanks :slight_smile:

    private bool TouchingBlueOrb;
    public int blueOrbForce;

Private variables (without the SerializeField attribute) won’t show up in the inspector, to begin with.
You could do this: Unity - Scripting API: Serializable
and make mini-classes – nb. I wouldn’t do this , myself, unless I wanted to create the class anyways. But I believe it technically will collapse.

Overall, I think this is something you shouldn’t worry about. You use as many variables in the class as you need, and that’s just how it goes :slight_smile:

Your question raises so many questions :slight_smile:

You need to think about the variables or properties that you would want to expose in an Inspector panel. For example, I don’t think you’d want/need to expose something called “TouchingBlueOrb”… especially when it’s private… and so on…

Yes I realize that private variables don’t show up in the inspector and its my fault for putting it in the thread post, I wasn’t paying attention. I just need a way to easily sort through public variables so when they do build up as development continues I don’t have to go searching through a huge list of variables to find what I need to change.

I truly think that you’re getting ahead of yourself (worrying without need). Some scripts will have no visible variables, other scripts a few, and others still more (maybe even lots). But that’s how it goes. I think you’ll find a way to be okay.

Well alright. I just like to be organized.

I totally understand. :slight_smile:

And I guess I don’t know for sure how it will go for you… but you can proceed and see how it goes.

I know this is a late reply, but just for those who would still stumble upon it, Odin Inspector allows you to create customizable Inspector fields for Serialized variables, including collapsible menus. It’s a paid app, but if Unity are having a sale, it’s well worth picking up.