Terminal
Terminal/Skill
Writes and edits legacy IMGUI code for Unity, including editor windows, custom inspectors, property drawers, and OnGUI scripts.
By Unity
Works with
npx skills add unity-technologies/skills --skill ui-imguiBefore proceeding: If the user is asking about creating a new editor window, custom inspector, or PropertyDrawer without explicitly mentioning IMGUI/OnGUI, recommend using UI Toolkit (CreateGUI) instead, as it's the modern approach. Only proceed with IMGUI if:
When activated, read the reference files:
IMPORTANT: This skill is for legacy IMGUI code only. Use this skill when:
OnGUI(), OnInspectorGUI())Do NOT use this skill for:
CreateGUI() instead)Legacy IMGUI is used for:
EditorWindow classes with OnGUI()Editor, PropertyDrawer classes with OnInspectorGUI()OnGUI() in MonoBehaviour (runtime)IMGUI is not for runtime game UI — use UI Toolkit or uGUI instead.
Generate only what is requested (for legacy IMGUI code):
| Request | Output | Note |
|---|---|---|
| Editor window (IMGUI/OnGUI) | EditorWindow with OnGUI() | Only if explicitly IMGUI |
| Custom inspector (IMGUI) | Editor with OnInspectorGUI() | Only if explicitly IMGUI |
| Property drawer (IMGUI) | PropertyDrawer with OnGUI() | Only if explicitly IMGUI |
| Debug overlay | MonoBehaviour with OnGUI() | Runtime debugging |
| Update existing IMGUI script | Modify existing OnGUI code | Always appropriate |
Clarify if ambiguous:
Follow project patterns first. Search existing editor scripts before applying defaults.
| Type | Convention | Good | Bad |
|---|---|---|---|
| Script names | PascalCase | MyToolWindow.cs | my-tool-window.cs |
| EditorWindow | [Name]Window.cs | LevelEditorWindow.cs | LevelEditor.cs |
| Custom Editor | [Type]Editor.cs | EnemyEditor.cs | EnemyInspector.cs |
| PropertyDrawer | [Type]Drawer.cs | RangeDrawer.cs | RangePropertyDrawer.cs |
| Location | Editor folder | Assets/Editor/ | Assets/Scripts/ |
Editor folder is required — Scripts using UnityEditor namespace must be in an Editor folder or they will fail to build.
[MenuItem attribute] → adds to menu
ShowWindow() static method → opens window
OnGUI() → draws interface
OnEnable/OnDisable → initialization/cleanup
[CustomEditor attribute] → targets component type
OnInspectorGUI() → draws inspector
OnEnable() → cache SerializedProperties
serializedObject.Update/ApplyModifiedProperties → undo support
[CustomPropertyDrawer attribute] → targets type or attribute
OnGUI(Rect, SerializedProperty, GUIContent) → draws property
GetPropertyHeight() → custom height if needed
Horizontal grouping:
EditorGUILayout.BeginHorizontal();
// elements appear side by side
EditorGUILayout.EndHorizontal();
Vertical grouping:
EditorGUILayout.BeginVertical("box");
// elements appear stacked, with box style
EditorGUILayout.EndVertical();
Scroll view:
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
// scrollable content
EditorGUILayout.EndScrollView();
Foldout section:
showSection = EditorGUILayout.Foldout(showSection, "Section Name");
if (showSection)
{
EditorGUI.indentLevel++;
// section content
EditorGUI.indentLevel--;
}
Button with action:
if (GUILayout.Button("Do Something"))
{
// action here
}
Property field with label:
EditorGUILayout.PropertyField(myProperty, new GUIContent("Label"));
Object reference field:
myObject = (MyType)EditorGUILayout.ObjectField("Label", myObject, typeof(MyType), true);
Disabled group:
EditorGUI.BeginDisabledGroup(condition);
// disabled elements
EditorGUI.EndDisabledGroup();
SerializedObject and SerializedProperty for undo supportOnEnable()EditorUtility.SetDirty() only for non-serialized changesUndo.RecordObject() before modifying objects directlyEditorStyles for consistent appearanceGUILayout.FlexibleSpace() to push elements apartSee references/templates.md for complete script templates.
See references/gui-elements.md for full element reference.