Hello!
I have created an UMG editor widget utility blueprint and would like to open it at some point from my plugin C++ code. How can I achieve that?
I took a look into how in Blutility such an editor widget utility is run when you right click it and select “Run Editor utility Widget” in AssetTypeActions_EditorUtilityWidgetBlueprint.cpp". Unfortunately, this module does not export any of its symbols so I can’t link against it… Here was my attempt (inspired from FAssetTypeActions_EditorUtilityWidgetBlueprint::ExecuteRun):
void ULogListWidgetBase::OpenEditorUtilityWidgetWindow(UWidgetBlueprint* Blueprint)
{
if (Blueprint->GeneratedClass->IsChildOf(UEditorUtilityWidget::StaticClass()))
{
const UEditorUtilityWidget* CDO = Blueprint->GeneratedClass->GetDefaultObject<UEditorUtilityWidget>();
if (CDO->ShouldAutoRunDefaultAction())
{
// This is an instant-run blueprint, just execute it
UEditorUtilityWidget* Instance = NewObject<UEditorUtilityWidget>(GetTransientPackage(), Blueprint->GeneratedClass);
Instance->ExecuteDefaultAction();
}
else
{
FName RegistrationName = FName(*(Blueprint->GetPathName() + LOCTEXT("ActiveTabSuffix", "_ActiveTab").ToString()));
FText DisplayName = FText::FromString(Blueprint->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>(Blueprint);
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);
}
}
}
As I said, I can write this but even when I add Blutility to my list of dependencies, I get the following link errors:
error LNK2019: unresolved external symbol "private: static class UClass * __cdecl UEditorUtilityWidgetBlueprint::GetPrivateStaticClass(void)" (?GetPrivateStaticClass@UEditorUtilityWidgetBlueprint@@CAPEAVUClass@@XZ) referenced in function "public: static void __cdecl ULogListWidgetBase::OpenEditorUtilityWidgetWindow(class UWidgetBlueprint *)" (?OpenEditorUtilityWidgetWindow@ULogListWidgetBase@@SAXPEAVUWidgetBlueprint@@@Z)
error LNK2019: unresolved external symbol "public: class TSharedRef<class SDockTab,0> __cdecl UEditorUtilityWidgetBlueprint::SpawnEditorUITab(class FSpawnTabArgs const &)" (?SpawnEditorUITab@UEditorUtilityWidgetBlueprint@@QEAA?AV?$TSharedRef@VSDockTab@@$0A@@@AEBVFSpawnTabArgs@@@Z) referenced in function "public: static void __cdecl ULogListWidgetBase::OpenEditorUtilityWidgetWindow(class UWidgetBlueprint *)" (?OpenEditorUtilityWidgetWindow@ULogListWidgetBase@@SAXPEAVUWidgetBlueprint@@@Z)
Is it something impossible to do at the moment, opening the window of a custom editor widget utility? I must have missed something