[CustomEditor(typeof(MyScript))]
public class MyScriptEditor : Editor
{
private bool showFields;
public override void OnInspectorGUI()
{
// The Foldout stores a bool describing whether the foldout is expanded or not
showFields = EditorGUILayout.Foldout(showFields, "Display Fields");
// If the foldout is expanded, display all the values
if (showFields)
{
EditorGUI.indentLevel++;
// Use this to display everthing, or write code for a more customized editor here
DrawDefaultInspector();
EditorGUI.indentLevel--;
}
}
}