Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException: Object reference not set to an instance of an object UnityEditor.EditorStyles.get_helpBox () #14

Open
mages-gamedev opened this issue Feb 21, 2019 · 3 comments

Comments

@mages-gamedev
Copy link

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) };
@MingFengShang
Copy link

	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();
               ……
       }

@delzrm
Copy link

delzrm commented Jul 21, 2020

any fix for this?

@jaredstorm
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants