Asset Management
Asset: An object imported from project file. One project file can be imported into many assets, like a png tileset image can be imported into many sprite assets.
AssetDatabaseCRUD for project assets- Operates on project relative paths and asset GUIDs
ResourcesAllows you to find and access Objects including assets- Can load assets without project relative paths
AssetPostprocessor&AssetModificationProcessorTake action after asset importPrefabUtilityInspect / Modify Prefabs- Instantiate prefabs in the scene as “prefab instances” and not regular game objects
- Create prefab variants
- Add components
- Apply overrides
- Supports
Undoout of the box
UnityEditorInternal.InternalEditorUtility.LoadSerializedFileAndForgetLoads assets from outside of the project folder- Special Folder Names
Entry points
InitializeOnLoadAttribute&InitializeOnLoadMethodAttributeAllows you to initialize an Editor class when Unity loads, and when your scripts are recompiledEditorApplication.delayCallDelegate which is called once after all inspectors update.EditorApplication.updateSimilar toMonobehaviour.Updatebut for editor only use
UI
Entry points
Menu Items
MenuItemCreate a menu itemContextMenuCreate object specific context menu items. Works onMonoBehaviourandScriptableObjectclasses. Right click on object inspector header to show menuContextMenuItemAttributeSame as above but works on serialized fieldsIHasCustomMenuDefines a method to add custom menu items to an Editor WindowEditorApplication.contextualPropertyMenuCallback raised whenever the user contex-clicks on a property in an InspectorUnityEditor.SceneManagement.SceneHierarchyHooksAdd menu items to Hierarchy windowaddItemsToCreateMenuaddItemsToGameObjectContextMenuaddItemsToSceneHeaderContextMenuaddItemsToSubSceneHeaderContextMenu
Editors
EditorCreate a custom “Inspector view” for the specific component or scriptable objectAssetImporters.AssetImporterEditorCreate a custom editor for theAssetImporters.ScriptedImporterObjectPreviewCreate a custom preview for specific component or scriptable objectPropertyDrawerCustomize input field for your serializable c# type
Windows
EditorWindowCreate custom windowsPopupWindow&PopupWindowContentCreate a popup windowScriptableWizardEditor window designed for quick object creation toolsSettingsProviderCreate custom view in Preferences or ProjectSettings windows
Addons
Overlays.OverlayCustomizable panels and toolbarsEditorTools.EditorToolCustom tools are like the built-in Move, Rotate, Scale tools or component specific tools like colider bounds editorEditorApplication.projectWindowItemOnGUICustomize project window itemsEditorApplication.hierarchyWindowItemOnGUICustomize hierarchy window itemsEditor.finishedDefaultHeaderGUIAdd UI to the default header drawer in Inspector Window
UI Systems
- UI Toolkit
- Namespaces
UnityEngine.UIElementsandUnityEditor.UIElements
- Namespaces
- IMGUI (Legacy)
- Static classes:
GUI,GUILayout,EditorGUI,EditorGUILayout
- Static classes:
Scene View UI
GizmosDraw things like tool handles or bounding boxesDrawGizmoSupply a gizmo renderer for any componentHandlesCustom 3D GUI controls and drawing in the Scene viewHandleUtilityHelper functions for Scene View style 3D GUIOverlays.OverlayCustomizable panels and toolbars
Utility
EditorGUIUtility.isProSkinis user using a dark or light editor theme
Serialization
JsonUtilityJSON serializerEditorJsonUtilityJSON serializer that will include editor only values of the engine objects (MonoBehaviour,ScriptableObject, etc.)SerializedObject&SerializedPropertyWhen you want to modify a component/asset avoid modifying it directly, instead use this API to properly save assets, scenes, supportUndoetc.UndoWhen modifying scene objects or assets use this class to support undo featureISerializationCallbackReceiverAdd logic to serialization eventsMonoBehaviour.OnValidate&ScriptableObject.OnValidatecalls when a value changes in the InspectorEditorPrefsSave and load data. Warning: Editor prefs are shared between all unity projects on user mashine. For project/tool/sdk editor only settings useScriptableSingleton<T>orScriptableObjectinstead.ScriptableSingleton<T>In classes that derive from ScriptableSingleton, serializable data you add survives assembly reloading in the Editor. Also, if the class uses the FilePathAttribute, the serializable data persists between sessions of Unity.
Native Popups
EditorUtility.DisplayDialogGet confirmation from the userEditorUtility.DisplayPopupMenuOpen context menu- Get the user select path
- Progress bar
EditorGUIUtility.GetMainWindowPositionGets editor window rect
Icons
Certain functions that load or set editor icons will find the appropriate texture for the active editor theme if certain conditions are met
- Icon textures for light and dark themes are in the same directory
- Dark theme icon name starts with the prefix: “d_”
- The icon name, path or texture passed to the function was pointing to the light version of the image
Example:
1 2 3 4 5 6 7 8 9 10 11 12// Assuming the editor theme is set to dark // and there are two icons located at Assets/myIcon.png and Assets/d_myIcon.png // This will return the Assets/d_myIcon.png because Editor theme is set to dark var darkIcon = EditorGUIUtility.IconContent("Assets/myIcon.png").image; // This will return the Assets/myIcon.png because AssetDatabase.LoadAssetAtPath always returns the exact asset var icon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/myIcon.png"); var monoImporter = (MonoImporter)AssetImporter.GetAtPath("Assets/SomeScript.cs"); // This will set the icon to Assets/d_myIcon.png because Editor theme is set to dark monoImporter.SetIcon(icon);
- Iconography
EditorGUIUtility.IconContentLoad icon texture from editor resources. Find icons in Editor Icon BrowserMonoImporter.SetIconSets a custom icon to associate with the imported MonoScript.PluginImporter.SetIconSets the custom icon to associate with a MonoScript imported by a managed plugin (like .dll).EditorGUIUtility.SetIconForObjectSet icon texture for GameObject or MonoScript.EditorGUIUtility.SetIconSizeChange IMGUI size of the icon.
Advanced / Tricks
CustomEditorForRenderPipelineAttributeTells an Editor class which run-time type it’s an editor for when the given RenderPipeline is activatedIMGUI.Controls.TreeViewIMGUI TreeViewIMGUI.Controls.AdvancedDropdownDropdown with pages as in “Add Component” button.- Open About Unity menu and type “internal” to toggle editor developer mode.
- Reload and inspect the editor window from its tab context menu
- Enable “Debug-Internal” inspector mode from the tab context menu
- Bunch of other internal tools, you can look for those in Unity C#Reference repo
Misc
EditorGUIUtility.hierarchyModeReason whyFoldoutcan behave differently in inspector view. Unity AnswersEditorInternalUtility.IsValidFileName
Resources
Useful Internals
Those are internal classes/methods that I found and thought might be useful. As with any internal stuff your need to keep in mind that this functionality is subject to change.
ScriptAttributeUtility.GetFieldInfoFromPropertyScriptAttributeUtility.GetDrawerTypeForType- You can create an assembly with a name like “Unity.InternalAPIEditorBridge.” that has access to the editor’s internal API. To find possible indexes search editor source code
