How to make Unity menus?

Hi everyone, The ORK RPG kit (as seen here) has a menu in unity that allows its user to edit his/her own database of items or monsters or whatever from a helpful gui in the actual unity 3d editor (not in game). I’d like to be able to create menus like that to make map tweaking a bit easier. does anyone know how the creator did this?

Well you do still use OnGUI, you derive a class from EditorWindow - put it in an editor folder and add menu items by having static functions / methods that are decorated with an attribute:

[UnityEditor.MenuItem ("MyMenu/Something/SomethingElse")]
public static void AMenu () {
          //Open a new window
          var instance = EditorWindow.GetWindow<MyClass>("My Windows Name");

    }

You can make other menu items that don’t have a window and just do something in an editor class in the same way, the function is called when the menu is selected.

You can also use OnInspectorGUI() which despite the name isn’t a 80’s cartoon for kids, but a place to put OnGUI calls when you write a custom inspector. Custom inspectors derive from Editor and are decorated like this: [CustomEditor(typeof(TheClassThatIEdit))]. A custom editor’s OnInspectorGUI needs to be overridden rather than just defined like most Unity functions and the derived class contains a target variable which is the item being inspected. So you do things like this:

protected override OnInspectorGUI() 
{
       var myObject = (TheClassThatIEdit)target;
       myObject.someBoolValue = GUILayout.Toggle(myObject.someBoolValue, "Some Bool Value");
}

See here for more details: http://unity3d.com/support/documentation/Components/gui-ExtendingEditor