Types
UEdMode
Base class for all editor modes.
Misc Entry points
- Get the
FTabManagerrepresenting the Editor Modes withFLevelEditorModule::GetLevelEditorTabManager- Snippet:
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor")andTSharedPtr<FTabManager> LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager().
- Snippet:
- Get
FEditorModeToolswithSLevelEditor::GetEditorModeManagerorGLevelEditorModeTools. - Get
FEditorModeRegistrywith the staticGetmethod.
Editor Mode Anatomy
Each mode has a Toolkit and commands.
Add custom Editor Mode
- See
Sample Tools Editor Modeplugin which is very small and contains an example on how to implement a new editor mode in UE5+.
But basically you make a subclass of UEdMode and FModeToolkit in a editor module. As well as a TCommand class that you will register in your module.
In your toolkit class implement GetInlineContent so show a widget in the empty panel.
Engine Registration of Editor Modes
When FCoreDelegates::OnAllModuleLoadingPhasesComplete is broadcasted UAssetEditorSubsystem::RegisterEditorModes is run.
This will iterate all UEdMode objects.
After a few checks and if the mode isn’t already registrated, we add it to the EditorModes array.
FEditorModeRegistry::CreateMode is used for legacy modes going through ULegacyEdModeWrapper::CreateLegacyMode.
Engine Creation Editor Mode
When SLevelEditor::RefreshEditorModeCommands is called and will handle mapping actions which triggers SLevelEditor::ToggleEditorMode on editor UI click.
Engine Changing Editor Mode flow
When switching Editor Mode SLevelEditor::ToggleEditorMode is called with the mode ID.
This will eventually call FEditorModeTools::ActivateMode
FEditorModeTools holds an array of currently active editor modes (See ActiveScriptableModes and IsModeActive/GetActiveScriptableMode).
If it can’t “recycle” the mode that needs to be activated, it will call UAssetEditorSubsystem::CreateEditorModeWithToolsOwner, which looks an internal EditorModes array.
It the mode was changed EditorModeIDChangedEvent delegate is broadcasted.