I´ve created a greater EditorWindow, which should be the AllInOne Editor for 4-5 Scripts of my Scene Setup Object.
So now, every of these 4-5 Scripts will get such an Inspector override attached:
[CustomEditor(typeof(Sys_Vocab))]
public class Sys_VocabEditor : Editor
{
public override void OnInspectorGUI()
{
if(GUILayout.Button("Open Vocab Editor")){
File.WriteAllText("crml.dat", (2).ToString());
EditorWindow.GetWindowWithRect(typeof(Editor_Scene_Setup), new Rect(0, 0, 800, Screen.height));
GUIUtility.ExitGUI();
}
}
}
This should open the EditorWindow, and show the Script depending Stuff by asking what ID “private int EditorFenster;” is set to.
EditorFenster is set by reading out “crml.dat”, which is filled with only the ID integer by the Inspector overrides.
The Problem:
If i open the EditorWindow via my Topmenü Setting (GameObject > Create Other > Scene_Setup), everything runs fine!
When clicking the Button in the Inspector, i get this:
Any idea what could be wrong here, and how to solve that Error Stuff?
The error has to do with trying to show the Vocabs section right away in the EditorWindow. It is a simple enough fix. Setup the code to run through OnGUI 2 or 3 times in Editor_Scene_Setup with EditorFenster=0 prior to reading from the crml.dat file. I tested it out and the errors went away in the test project by doing this.
Updated now that I have time to share more details… here are changes I made. Also improved upon the original solution I did.
Removed this section of code from OnGUI: if (File.Exists("crml.dat")) { ... }
Added the following properties to the Editor_Scene_Setup class…
Found a Solution for the ArgumentException Error.
I needed to place the File Reader as last step in OnGUI, so OnGUI runs first with EditorFenster as 0, and sets itself via File readout to the new value.