in-editor scripting

Hi all. My apologies if this has been answered but I’m having a hard time searching for it because the term “scripting” is so over-loaded.

In this video:

the author has a script where he can click buttons to automate editor tasks, such as adding blocks to the scene. I would like to learn how to create a script with this type of functionality and I was hoping someone could point me in the right direction. Thank you very much!

Your best bet is to read this.

This allows you to create a new unity editor window, to which you can attach all sorts of scripts. He did a lot of scripting to get the wonderful effects like that, but the above link is where you start.

Excellent! That’s what I was looking for, thanks!

Okay, i tried following the docs that Siegeon linked me to but I can’t seem to get it working. I’ve created a JavaScript class called TileEditor in a folder called Editor in my project assets that contains the following:

class MyWindow extends EditorWindow {
    @MenuItem ("Window/My Window")
    static function ShowWindow () {
        EditorWindow.GetWindow (MyWindow);
    }

    function OnGUI () {
        // The actual window code goes here
    }
}

exactly like the docs say. But…now what? The docs simply state that “this will create a window”…but how do I open this window? I thought using the @MenuItem line would put it under the Window menu in Unity but I don’t see it.

Thanks!

Aha, okay. It wasn’t working because I had an error somewhere in my project. I now see an entry called MyWindow in the Window menu at the top but when I try to open it I get a nullref. Do I need to create a MenuItem or something?

Got it. The name of my class didn’t match up with the code. It’s working now, woo!