Download

How to make an EditorUtilityWidget open/run via C++

Hey,
I am working on a UE4 project for university and I am creating a small editor plugin to procedurally generate buildings.

Unfortunately I can not seem to find a way to start the editor utility widget by pressing the toolbar button/using C++.
I already tried to use CreateWidget, but it does not seem to work with EditorUtilityWidgets.

I realized that there is very little information to find for this problem.
Does anyone have an idea how to run an EditorUtilityWidget via C++?

Best regards

Hi,
In c++ you cas use this code for run editor utility widget

void YourClassName::RunEditorUtilityWidget(UEditorUtilityWidgetBlueprint* EditorWidget)
{
	if (EditorWidget)
	{
		UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
		EditorUtilitySubsystem->SpawnAndRegisterTab(EditorWidget);
	}
}

Or in blueprint there are tutoriel on the Wiki

Ah thanks for the function!

Unfortunately I can’t get the reference to the Widget right.
Do you also know how to properly reference the EditorWidget, since I can’t seem to get it to work with ConstructorHelper::ClassFinder.

This is the code I want to use when pressing the toolbar button:

void FPlugiModule::PluginButtonClicked()
{

static ConstructorHelpers::FClassFinder<UEditorUtilityWidgetBlueprint> BBObj(TEXT("/Game/BB"));
if (BBObj.Succeeded()) {
	//MenuClass is TSubclassOf<class UEditorUtilityWidgetBlueprint> MenuClass;
	MenuClass = BBObj.Class;
}

//Does not work as it can't convert UClass to UEditorUtilityWidgetBlueprint
RunEditorUtilityWidget(MenuClass.Get());

}