Hello All,
Couple of questions regarding extending the editor using C# rather than Javascript (not a fan of Javascript syntax, and know C# much better than I know Javascript!)
-
Get an error saying that EditorWindow is not a known type - suspect I haven’t included the appropriate namespace, but I can’t seem to find out what that namespace is - anyone know?
-
how do I do the @MenuItem (“Window/My Window”) in C#?
Thanks to anyone who is able to help!
You sir are a genius!
Getting another error with this though:
public class NodeGraph : MonoBehaviour {
[MenuItem(“Window/My Window”)]
static void ShowWindow () {
EditorWindow.GetWindow (new NodeGraph());
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGui()
{
}
}
Assets/Editor/NodeGraph.cs(10,21): error CS1502: The best overloaded method match for `UnityEditor.EditorWindow.GetWindow(System.Type)’ has some invalid arguments
Wrong class there you extend.
you want to extend EditorWindow, not MonoBehaviour
I recommend to give the Script Reference a look to see what functions the EditorWindow class offers and what callbacks it offers
Ooops - needed a type - added GetType()
Doh - yes that isn’t exactly helping!
Thanks for your assistance!
Can’t use new with the editor window - tells me to use scriptableobject.createinstance, but get type doesn’t seem to work with this. Any way I can get the type another way?
Okay - solved - if anyone has the same issue you need to use:
EditorWindow.GetWindow (typeof(YourWindow));