The question is answered, right answer was accepted
My EditorWindow won't display properly, even when commented out.
Hey,
I recently made an editor script and it was working fine. I added a line of code that didn't work, so I removed it. Now, every time I open the editor window, it doesn't appear despite all of my Debug.Log()'s going off, no errors showing up in the console, and none of my try's being caught.
This small editor-window-esque bit shows up sometimes in the top left: https://gyazo.com/5cebcc959a395aa36c7f621766144db4
My code, despite it being sloppy right now and not useful:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
public class ItemEditor : EditorWindow {
[MenuItem("Durian Utilities/Item Editor")]
public static void ShowWindow()
{
GetWindow(typeof(ItemEditor));
}
private void OnFocus()
{
//initItems();
}
List<InventoryItem> items = new List<InventoryItem>();
private void initItems ()
{
Debug.Log("Got this far");
items = Resources.LoadAll<InventoryItem>("Items").ToList();
int id = 0;
foreach(InventoryItem item in items)
{
item.id = id;
id++;
}
Debug.Log("And this far, too");
Focus();
}
private void OnGUI()
{
Debug.Log("Made it to ONGUI");
position = new Rect(new Vector2(-1920,0), new Vector2(500, 500));
GUILayout.Label("Item Editor © Vextin 2027", EditorStyles.centeredGreyMiniLabel);
//a bunch of stuff down here is commented out
}
}
}
I guarantee that this isn't a script issue, but may as well give details.
I'm using Unity 5.6.0f3
So, does anyone know of a reason for this to not be working?
EDIT: I just made a separate script and it doesn't display its window either.
Relaunched Unity and got the errors
Removed empty DockArea while reading window layout: window #5, instanceID=11774 UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
and
Error while reading window layout: window #1 is null UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
None of my custom editors are loading, still.
The error message you're getting is because your window layout has serialized some window, but the Editor cannot find the type for it or had some other deserialization problem.
If this example you pasted is verbatim what is in your project, you have an extra closing brace right after //a bunch of stuff down here is commented out
. If this is not a compiler error issue though, try resetting to the Default window layout (top right of the editor) and see if the problem goes away.
Solved. I'm really fucking confused.
I took your advice and ran with it. I reset the layout, which actually resulted in a bug that had me restart the unity editor but it was fine. I then checked class names. As it turns out, the other editors I made to see if it was a Unity-wide bug were still instantiating a window of the class ItemEditor
so they weren't actually different at all. Finally, the position = new Rect(new Vector2(-1920,0), new Vector2(500, 500));
line, despite me tweaking the values to anywhere between (-1920, -1080) to (1920, 1080) and every conceivable place in between, were hiding the editor.
Thanks for your help!
Got this error suddenly after upgrading to Unity 5.6.1 from 5.5.1 :/ Restarting Unity fixed the problem for me.
Follow this Question
Related Questions
Editor Int sliders affecting each other 0 Answers
GUI.Window. Wanting to allow clickthrough 0 Answers
How to change the text of EditorGUILayout.TextField 2 Answers
How to Have a ReoderableList in a Custom Editor Window 1 Answer
Do Unity Editor GUI Utilities (Handles.DrawLine & EditorGUI.DrawRect) have limitations? 2 Answers