Have you ever noticed that some Unity built-in components have this particular behaviour to show some variables in the inspector only when you select a specific option, like setting the value of a boolean or a enum?
E.G. When you set “Automatic center of mass” or “Automatic Tensor” to false in the Rigidbody component, the inspector displays a new section:
I’ve always wondered how this useful feature is implemented.
I was searching some Discussions concerning this problem and the only solution that I found out was using a Custom Property Drawer. I honestly don’t know if that’s the real solution, because it seems a bit out of my scope.
Do I really need to customize the Property Drawer? I thought there was an easier way, like some Unity attributes idk
Do you recommend any free addon? I feel like creating a custom editor from scratch is a bit too much for me and it slows down my workflow for the whole project
If you’re looking for a plugin that achieves this with just attributes, you can try NaughtyAttributes, which I have heard of but never used myself. But the first example they have is an [EnableIf] attribute.