Inspector sub-menu?

In the Unity inspector, how can I make variables appear in a sub-menu(where there is a small arrow next to the category, and If it is clicked it displays the rest of the individual variables). Several scripts that come with unity have this, but from looking at the code, I have not been able to figure out how to do this. Thanks

use the EditorGUILayout.Foldout() field.

public class MyInspector : Editor
{
    static bool foldout = false;

    public void override OnInspectorGUI()
    {
        foldout = EditorGUILayout.Foldout( foldout, "My Foldout" );
        if( foldout )
        {
            EditorGUI.indentLevel = EditorGUI.indentLevel + 1;

            // More fields here

            EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
        }
    }
}

I’ve added a feedback item to have attribute based categories added to the default inspector.

Please go here and vote for it:

http://feedback.unity3d.com/suggestions/built-in-inspector-should-use-system-dot-componentmodel-attributes-category-description-like-the-winforms-propertygrid

I’ve added a feedback item to have attribute based categories added to the default inspector.

Please go here and vote for it:

http://feedback.unity3d.com/suggestions/built-in-inspector-should-use-system-dot-componentmodel-attributes-category-description-like-the-winforms-propertygrid