[HELP] Launching a EditorUtilityWidget from LevelEditorTab (Code in Post)

I’ve spent alot of time trying to get this to work. I have a few variations in the same function if anyone wants to help point me in the right direction I would love that, i’m also sure people would love to be able todo this for their own plugins.

Currently i’m trying to launch a EditorUtilityWidget from the plugin’s content directory. Having a hardtime with that.


TSharedRef<class SDockTab> FExamplePluginModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
{
    FStringClassReference test = IPluginManager::Get().FindPlugin(TEXT("ExamplePlugin"))->GetContentDir() / TEXT("ExamplePlugin.ExamplePlugin");
    static ConstructorHelpers::FObjectFinder<UClass> testObj(TEXT("Blueprint '/ExamplePlugin/Content/ExamplePlugin.uasset'"));
    UClass* testClass = test.TryLoadClass<UEditorUtilityWidget>();

    UObject* testObj = test.TryLoad();
    UWorld* World = GEditor->GetEditorWorldContext().World();
    check(World);
    UEditorUtilityWidget* CreatedUMGWidget = CreateWidget<UEditorUtilityWidget>(World, testClass);
    //CreatedUMGWidget = CreateWidget<UEditorUtilityWidget>(World, (UClass*)testObj.Object->GetClass());
    TSharedRef<SWidget> TabWidget = SNullWidget::NullWidget;
    TSharedRef<SWidget> CreatedSlateWidget = CreatedUMGWidget->TakeWidget();
    TabWidget = SNew(SVerticalBox)
        + SVerticalBox::Slot()
        .HAlign(HAlign_Fill)
        
            CreatedSlateWidget
        ];
    TSharedRef<SDockTab> SpawnedTab = SNew(SDockTab);

    SpawnedTab->SetContent(TabWidget);
    return SpawnedTab;
    /*
    FStringClassReference test = IPluginManager::Get().FindPlugin(TEXT("ExamplePlugin"))->GetContentDir() / TEXT("ListAssetIssuers.ListAssetIssuers_C");

    UClass* testClass = test.TryLoadClass<UEditorUtilityWidget>();
    UObject* testObj = test.TryLoad();

    FName RegistrationName = FName(*(testObj->GetPathName() + LOCTEXT("ActiveTabSuffix", "_ActiveTab").ToString()));
    FText DisplayName = FText::FromString(testObj->GetName());
    FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
    TSharedPtr<FTabManager> LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager();
    if (!LevelEditorTabManager->CanSpawnTab(RegistrationName))
    {
        IBlutilityModule* BlutilityModule = FModuleManager::GetModulePtr<IBlutilityModule>("Blutility");
        UEditorUtilityWidgetBlueprint* WidgetBlueprint = Cast<UEditorUtilityWidgetBlueprint>(testObj);
        WidgetBlueprint->SetRegistrationName(RegistrationName);
        LevelEditorTabManager->RegisterTabSpawner(RegistrationName, FOnSpawnTab::CreateUObject(WidgetBlueprint, &UEditorUtilityWidgetBlueprint::SpawnEditorUITab))
            .SetDisplayName(DisplayName)
            .SetGroup(BlutilityModule->GetMenuGroup().ToSharedRef());
        BlutilityModule->AddLoadedScriptUI(WidgetBlueprint);
    }
    TSharedRef<SDockTab> NewDockTab = LevelEditorTabManager->InvokeTab(RegistrationName);
    return NewDockTab;
    */
    /*
    FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
    TSharedPtr<FTabManager> LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager();
    //UEditorUtilityWidget* pidget = CreateWidget<UEditorUtilityWidget>(GEditor->GetEditorWorldContext().World(), testClass->GetDefaultObject());

    TSubclassOf<UEditorUtilityWidget> WidgetClass = testClass;
    UWorld* World = GEditor->GetEditorWorldContext().World();
    check(World);
    UEditorUtilityWidget* pidget = CreateWidget<UEditorUtilityWidget>(World, WidgetClass);
    TSharedRef<SDockTab> SpawnedTab = SNew(SDockTab);
    SpawnedTab->SetContent(pidget);
    UEditorUtilityWidget* Instance = NewObject<UEditorUtilityWidget>(GetTransientPackage(), testClass);

    return SpawnedTab;
    */


    //if (UClass* EditorWidgetClass = editorWidget.TryLoadClass<)
    /*
    FText WidgetText = FText::Format(
        LOCTEXT("WindowWidgetText", "Add code to {0} in {1} to override this window's contents"),
        FText::FromString(TEXT("FExamplePluginModule::OnSpawnPluginTab")),
        FText::FromString(TEXT("ExamplePlugin.cpp"))
    );

    return SNew(SDockTab)
        .TabRole(ETabRole::NomadTab)
        
            // Put your tab content here!
            SNew(SBox)
            .HAlign(HAlign_Center)
        .VAlign(VAlign_Center)
        
            SNew(STextBlock)
            .Text(WidgetText)
        ]
        ];
        */
}