Editor windows in Unity 4?

Hey, I’m trying to make an editor window so I just copied the code from the script reference but it doesn’t work? I changed all the names to the name of my script??? Has something changed, it has a option in the “window” tab but clicking on this returns nothing? And it is in the “Editor” folder.

This is the code:

// JavaScript example:
class UVsprite extends EditorWindow 
{
    var myString = "Hello World";
    var groupEnabled = false;
    var myBool = true;
    var myFloat = 1.23;
    
    // Add menu named "My Window" to the Window menu
    @MenuItem ("Window/UVsprite")
    static function Init () 
    {
        // Get existing open window or if none, make a new one:        
        var window = ScriptableObject.CreateInstance.<UVsprite>();
    }
    
    function OnGUI () 
    {
        GUILayout.Label ("Base Settings", EditorStyles.boldLabel);
            myString = EditorGUILayout.TextField ("Text Field", myString);
        
        groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
            myBool = EditorGUILayout.Toggle ("Toggle", myBool);
            myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
        EditorGUILayout.EndToggleGroup ();
    }
}

in unity 4 free edition?or pre ordered beta version u using?

Some doc samples are way outdated.
Try this intead of ScrptableObject:

var window : UVsprite = EditorWindow.GetWindow(UVsprite, true, "UV Window");

To build editor tools at some point you would be better off JS and use C# though :stuck_out_tongue:

The free. unity 4.0.0f3(I think)

Yeah that didn’t work :frowning: I tried changing Init to Initiate as well but no luck :frowning:

its very frustrating that they let their docs go, they used to be some of the best but now there is probably like 20-30% are wrong and don’t work… They need to update the reference as soon as they add or change something and each web page needs a last edited time, I also think a wiki section built in to this would be great, so anyone can put up example scripts and info.

And yeah i probably should use c# but I find US more readable and ATM i’m not doing anything complex.

In JS you need to call window.Show(); else it won’t work. Weird! UnityScript is so… meh
Tried this and it works here:

class UVsprite extends EditorWindow {

    var myString = "Hello World";

    var groupEnabled = false;

    var myBool = true;

    var myFloat = 1.23;

    static var myWindow : UVsprite;

    // Add menu named "My Window" to the Window menu

    @MenuItem ("Window/UVsprite")

    static function Init() 

    {

       myWindow = ScriptableObject.CreateInstance.<UVsprite>();
		myWindow.Show();
    }

    

    function OnGUI () 

    {

        GUILayout.Label ("Base Settings", EditorStyles.boldLabel);

            myString = EditorGUILayout.TextField ("Text Field", myString);

        

        groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);

            myBool = EditorGUILayout.Toggle ("Toggle", myBool);

            myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);

        EditorGUILayout.EndToggleGroup ();

    }

}

Ah, thanks :slight_smile: