I want to write custom inspector for one of my scripts. All I want to change is input method for one of the strings to popup (so instead of writing whole string everytime I choose it from premade list of strings, like enums).
But the thing is it’s VERY long inspector with a lot of variables and rewriting everything just for this one input just doesn’t click for me. I’m very happy with how default inspector shows all the fields, expect this one string I want to change. Is there a way to do it without rewriting whole inpector on your own?
Yes this kind of thing is certainly possible.
We have our own version of DrawDefaultInspector, which has a parameter allowing us to pass in a list of names of properties that we don’t want it to draw.
It works by iterating over the SerializedObject’s SerializedPropertys, calling EditorGUILayout.PropertyField to draw each property unless the property’s name is found in the “don’t draw” list.
A custom inspector can use this to draw the bulk of the inspector, and then handle the excluded properties in its own way.
The custom inspector calls this function, then does its own thing to draw the properties that have been excluded.