I’m working on a plugin that saves and loads viewport settings. But I can’t seem to figure out how to get and set the viewport layout configuration for the active level editor viewport. I’ve been looking into the FLevelViewportLayout class but, I’m not sure how to get an instance of it from the active viewport.
I managed to figure it out, here is what is working for me:
void FLyraModule::SetQuadView()
{
// Get the current level editor
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
TSharedPtr<ILevelEditor> LevelEditor = LevelEditorModule.GetFirstLevelEditor();
if (LevelEditor.IsValid())
{
// Get the active viewport
TSharedPtr<FUICommandList> CommandList;
if (TSharedPtr<SLevelViewport> ActiveLevelViewport = LevelEditor->GetActiveViewportInterface())
{
CommandList = ActiveLevelViewport->GetCommandList();
}
CommandList->ExecuteAction(FLevelViewportCommands::Get().ViewportConfig_FourPanes2x2.ToSharedRef());
}
}