ReorderableInspector
ReorderableInspector copied to clipboard
NullReferenceException: Object reference not set to an instance of an object UnityEditor.EditorStyles.get_helpBox ()
Upon recompilation of scripts, an error consistently pops up
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.EditorStyles.get_helpBox () (at C:/buildslave/unity/build/Editor/Mono/GUI/EditorStyles.cs:195)
SubjectNerd.Utilities.ReorderableArrayInspector.InitInspector () (at Assets/ThirdParty/SubjectNerd/ReorderableInspector/Editor/ReorderableArrayInspector.cs:326)
SubjectNerd.Utilities.ReorderableArrayInspector.OnEnable () (at Assets/ThirdParty/SubjectNerd/ReorderableInspector/Editor/ReorderableArrayInspector.cs:311)
This is the line throwing the null ref error:
styleEditBox = new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(5, 5, 5, 5) };
private void OnEnable()
{
//InitInspector();
}
……
protected bool InspectorGUIStart(bool force = false)
{
InitInspector();
Repaint();
// Not initialized, try initializing
//if (hasSortableArrays && listIndex.Count == 0)
// InitInspector();
//if (hasEditable && editableIndex.Count == 0)
// InitInspector();
……
}
any fix for this?
@delzrm -- This isn't a real fix, but you can at least suppress the errors by wrapping the offending line with a try/catch.
try {
styleEditBox = new GUIStyle(EditorStyles.helpBox) { padding = new RectOffset(5, 5, 5, 5) };
} catch (Exception) {
}
You're not really supposed to use try/catch like this since it's terrible for performance, but seeing as it's in an initialization method in an Editor script, it's not really a performance critical segment of code.