I’m creating an editor window that includes functions for opening scenes. It’s working and the scenes open, but I’m getting null reference errors that I can’t get rid of:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.DockArea.EndOffsetArea ()
UnityEditor.DockArea.OnGUI ()
Anyone know how to fix this?
Below is a script I’ve tested in a new project. The test scenes have nothing in them except a cube and a sphere.
class TestWindow extends EditorWindow {
@MenuItem("Window/TestWindow")
static function Init() {
var window : TestWindow = EditorWindow.GetWindow(TestWindow);
}
function OnGUI() {
var openTest1 : boolean = false;
EditorGUILayout.BeginHorizontal();
if(GUILayout.Button("Test1", EditorStyles.toolbarButton, GUILayout.Width(100))) {
openTest1 = true;
//EditorApplication.SaveCurrentSceneIfUserWantsTo();
//EditorApplication.OpenScene("Assets/Test1.unity");
//return;
}
if(GUILayout.Button("Test2", EditorStyles.toolbarButton, GUILayout.Width(100))) {
EditorApplication.SaveCurrentSceneIfUserWantsTo();
EditorApplication.OpenScene("Assets/Test2.unity");
return;
}
EditorGUILayout.EndHorizontal();
if(openTest1) {
EditorApplication.SaveCurrentSceneIfUserWantsTo();
EditorApplication.OpenScene("Assets/Test1.unity");
}
}
}
Cheers! This really should be demonstrated and explained in the button documentation.
– numberkruncher