Skip to content

Common Unity Custom Editor Errors and How to Fix Them

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.

Summary

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!

Published inCode ExamplesDevelopment Tips

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *