The DrawDefaultInspector Function official tutorial from Editor Scripting topic

I am watching “The DrawDefaultInspector Function” from Editor Scripting topic.

All public variables are appearing in the inspector view in spite of the fact that there is not any Editor Script. Why? In this tutorial public variables are not appearing in the inspector view.

I'm having the script check the trigger to see if its active while doing a function and if it is active it does a second function as well as the first. The trigger collider is attached to the player in front of him and he moves into the object The problem Im having is sometimes when I do another function or move weirdly the trigger would be false for some reason even when I was clearly in range. It's probably the bool turning false when it shouldn't be.

1 Answer

1

I’m not sure if i understand your problem. If you don’t write an explicit editor for your class, Unity automatically uses the default inspector for all of your custom MonoBehaviours. The public variables will disappear when you implement a custom inspector which explicitly draws nothing. That means you you have to create a custom editor for your class which overrides the OnInspectorGUI method, but does nothing in it.

As soon as you implement that editor, Unity will use that editor for your custom script. Since the OnInspectorGUI method is empty, nothing will be drawn.