Editor Scripting

Download

Unity Cheat Sheet: #30

Abhishek Smith

Abhishek Smith

Building Outscal | Land Jobs in the gaming industry | EA, Epic Games, TCS, | CMU, IIT K

Inspector Customization

  • EditorGUILayout: Create custom inspector fields
  • PropertyDrawer: Custom property rendering
  • CustomEditor: Complete inspector overhaul
  • SerializedProperty: Access serialized fields
  • ContextMenuItems: Right-click menu options


Layout Controls

  • BeginVertical/Horizontal: Organize elements
  • Space: Add spacing between elements
  • Indent: Nested inspector elements
  • Foldouts: Collapsible sections
  • PropertyScope: Property modification handling

Scene View Tools

  • Handles: Custom scene view controls
  • Gizmos: Visual debugging
  • SceneView.duringSceneGui: Custom overlays
  • HandleUtility: Scene view utilities
  • EditorWindow: Custom editor windows

Asset Management

  • AssetDatabase: Create/Delete/Move assets
  • PrefabUtility: Prefab operations
  • Selection: Editor selection control
  • EditorPrefs: Store editor preferences
  • ProjectWindowUtil: Project window operations

Editor Callbacks

  • OnSceneGUI: Scene view interaction
  • OnInspectorGUI: Inspector customization
  • OnEnable/OnDisable: Editor script lifecycle
  • EditorApplication.update: Editor updates
  • PostProcessScene: Scene build processing

Pro Tips:

  • Use Undo.RecordObject for modifications
  • Cache SerializedProperties for performance
  • Group related properties in foldouts
  • Add validation to custom fields
  • Use EditorGUIUtility.hierarchyMode

Best Practices:

  • Keep editor code in Editor folder
  • Use #if UNITY_EDITOR for editor-only code
  • Clean up resources in OnDisable
  • Implement proper Undo support
  • Handle multi-object editing

Show More