Drawdefaultinspector except of one variable?


So say I have a script that makes a custom inspector for anotherone. The target script has many variables and depending on the enum value I select I want to hide 2 of them. In other words when my enum is set to A I want all the variables of my script to appear in the inspector, but when it is set to B I want to all the variables to appear except of 2.

Do I have to write one line of code for each variable at my custom inspector script or is there a way to say drawDefaultInspector except of those 2 variables?

Instead of using DrawDefaultInspector(), use:

DrawPropertiesExcluding(serializedObject, "myProperty", "myOtherProperty);

As far as I know, yeah, you have to rewrite the whole inspector if you want to change the functionality of even one variable. Luckily, all of the predefined fields already have functions to display the same way they do normally.