- Home /
Open new editor window from editor class
Hi there! I have a script called GEditor. In this script I have a class:
class GEditor extends Editor {
override function OnInspectorGUI () {
//main code goes here
}
}
It's for extending my inspector. Now how would I add a button that will open new separate window without making separate script file? Is it possible? I tried adding new class extending EditorWindow(from the docs) but unity screams errors in my face(namespace taken, because "GEditor" is taken ). I tried inserting EditorWindow.GetWindow (docs), but that gives ambiguity errors.
So, is this possible without making a mess? Or unity programmers were having a bad day when implementing this?
Answer by Woj_Gabel_FertileSky · Jan 16, 2013 at 01:46 AM
Actually, I found a way. I didn't know it was so easy. I think my question was misleading.
Just do:
var window : myCustomWindow = EditorWindow.GetWindow(myCustomWindow ,false);
Answer by Loius · Oct 19, 2012 at 12:38 AM
Nope, Inspector and EditorWindow are different things and they -should- be in separate files - for your own safety. Extend Editor if you want the Inspector, extend EditorWindow if you want a floaty window.
You can create a paired relationship using two classes, just teach them how to talk to each other. I'd use static methods, myself.