I’ve been working on keeping track of common errors, so I don’t repeat them same mistakes and hopefully you all won’t either! Here are some common errors with Unity Custom Editors.
Variable Change Not Persisting in Custom Editor
There can be a few reasons for this. First ensure you’ve got at the start of your OnInspectorGUI function serializedObject.Update(); and serializedObject.ApplyModifiedProperties();. These functions update the object and apply your changes. If you’re modifying the target directly, then you’ll need to use EditorUtility.SetDirty(target); to apply those changes.
Null Reference Exception Accessing Variable in Property Field
In order to correct this, you’ll want to verify that the variable name is spelled right and that the variable is serializable. If you’re still having an issue, you may try initializing the variable to a default value.
That’s all for now, but I’ll add any new ones I find or you all add in the comments. Good luck with your games!