Editor Utility Widgets are one of the new feature of the Unreal Engine since 4.22. It allows users to define editor widgets using the UMG designer. We already covered this topic previously, so if you want to start with Editor Utility Widgets, you may want to check this article, this one and this one.
In this article, we will answer to a question we can have when using the Editor Utility Widgets: how can we programmatically start an Editor Utility Widget?
If you are wondering how an Editor Utility Widget can start another Editor Utility Widget, this article will explain you how to do it.
In the previous articles, the only way to start the Editor Utility Widget was to perform a right-click on it and select Run Editor Utility Widget. But it’s also possible to start it programmatically using C++ and blueprints.
Starting an Editor Utility Widget from C++
First of all, this is an editor only function, so we will need to create a new editor plugin (everything is explained for this in the previous article about Editor Utility Widgets in C++).
For this plugin, we will require several dependencies, so the following section must be added to the Build.cs:
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"UnrealEd",
"Blutility",
"UMG",
"UMGEditor"
// ... add private dependencies that you statically link with here ...
}
);
Then, in this plugin, we will create a UBlueprintFunctionLibrary. Actually, it can be any class, but we will only need to create a static function allowing us to start the Editor Utility Widget, so a UBlueprintFunctionLibrary is enough.
The header of this class will give something like this:
#include "CoreMinimal.h"
#include "Editor/Blutility/Classes/EditorUtilityWidget.h"
#include "Runtime/Engine/Classes/Kismet/BlueprintFunctionLibrary.h
#include "EditorWidgetFunctionLibrary.generated.h"
UCLASS(BlueprintType)
class CPPEDITORWIDGET_API UEditorWidgetFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
static void StartWidget(UWidgetBlueprint* Blueprint);
};
The important points to note here are the presence of a StartWidget static function taking as parameter a UWidgetBlueprint object. We may also note the required includes.
The corresponding part in the cpp file with the implementation of the function will be like this:
#include "EditorWidgetFunctionLibrary.h"
#include "Editor/UMGEditor/Public/WidgetBlueprint.h"
#include "Editor/LevelEditor/Public/LevelEditor.h"
#include "Runtime/Core/Public/Modules/ModuleManager.h"
#include "Editor/Blutility/Public/IBlutilityModule.h"
#include "Editor/Blutility/Classes/EditorUtilityWidgetBlueprint.h"
void UEditorWidgetFunctionLibrary::StartWidget(UWidgetBlueprint* Blueprint)
{
if (Blueprint->GeneratedClass->IsChildOf(UEditorUtilityWidget::StaticClass()))
{
const UEditorUtilityWidget* CDO = Blueprint->GeneratedClass->GetDefaultObject();
if (CDO->ShouldAutoRunDefaultAction())
{
// This is an instant-run blueprint, just execute it
UEditorUtilityWidget* Instance = NewObject(GetTransientPackage(), Blueprint->GeneratedClass);
Instance->ExecuteDefaultAction();
}
else
{
FName RegistrationName = FName(*(Blueprint->GetPathName() + TEXT("_ActiveTab")));
FText DisplayName = FText::FromString(Blueprint->GetName());
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked(TEXT("LevelEditor"));
TSharedPtr LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager();
TSharedRef NewDockTab = LevelEditorTabManager->InvokeTab(RegistrationName);
}
}
}
For information, this function is extracted from FAssetTypeActions_EditorUtilityWidgetBlueprint::ExecuteRun(FWeakBlueprintPointerArray InObjects) in AssetTypeActions_EditorUtilityWidgetBlueprint.h.
Once this code copied in the plugin, we have everything required to start an Editor Widget Utility from C++. We just need to call StartWidget with a reference on the UWidgetBlueprint we want to start.
Usage in blueprints
The function previously defined is exposed to blueprints (marked as BlueprintCallable), this means the plugin we created allow us to programmatically start Editor Utility Widgets using blueprints. Indeed, the StartWidget function is callable from other Editor Utility Widgets, so now an Editor Utility Widget can start another widget.
And it’s straightforward:
Here we just created a simple Editor Utility Widget with only one button, and on the click on this button we want to spawn another widget. And, the previous figure shows all we need to do to implement this.
Conclusion
This article presents how we can programmatically start an Editor Utility Widget using either C++ or blueprints (but with the creation of a C++ plugin being mandatory).
And just so you know, this article is actually a request from a reader willing to know how to programmatically start an Editor Widget Blueprint (right now there’s still a lack of documentation and ressources about Editor Utility Widgets). If you’re interrested in more articles about this, or if you want to request an article about a specific topic, you can follow us and contact us on Twitter and Facebook.
Thank you soo much for this Article!!! Helped me a lot!! 🙂
Hey! This is my 1st comment here so I just wanted to give a quick
shout out and say I really enjoy reading your blog posts.
Can you suggest any other blogs/websites/forums that go over the same
subjects? Thanks for your time!
Hey!. this anwser is not complete, you have to manually open your widget once, then it will register the tab with the unreal’s tab spawner.
you will need to register your tab first and the create a widget based on your tab spawner:
here you can update your blog:
if (!LevelEditorTabManager->CanSpawnTab(RegistrationName))
{
//UEditorUtilityWidgetBlueprint* WidgetBlueprint = Cast(Blueprint);
LevelEditorTabManager->RegisterTabSpawner(RegistrationName, FOnSpawnTab::CreateStatic(&UPipelineStatics::SpawnEditorUITab, Blueprint))
.SetDisplayName(DisplayName)
.SetMenuType(ETabSpawnerMenuType::Hidden);
}
and then you will need a function to create your widget inside the SpawnEditorUITab function:
TSharedRef UPipelineStatics::SpawnEditorUITab(const FSpawnTabArgs& SpawnTabArgst, UWidgetBlueprint* Blueprint)
{
TSharedRef SpawnedTab = SNew(SDockTab);
TSubclassOf WidgetClass = Blueprint->GeneratedClass;
UWorld* World = GEditor->GetEditorWorldContext().World();
check(World);
UEditorUtilityWidget* CreatedUMGWidget = CreateWidget(World, WidgetClass);
if (CreatedUMGWidget)
{
TSharedRef CreatedSlateWidget = CreatedUMGWidget->TakeWidget();
SpawnedTab->SetContent(CreatedSlateWidget);
}
return SpawnedTab;
}
this is without modifying any source code. just as a plugin
Perfect!
thank you so much! you really helped me on the most though step!
Great article but the cpp you posted does not work on 4.22 because of some compile errors.
Here’s a fixed version of it.
============================
#include “EditorWidgetFunctionLibrary.h”
#include “Editor/UMGEditor/Public/WidgetBlueprint.h”
#include “Editor/LevelEditor/Public/LevelEditor.h”
#include “Runtime/Core/Public/Modules/ModuleManager.h”
#include “Editor/Blutility/Public/IBlutilityModule.h”
#include “Editor/Blutility/Classes/EditorUtilityWidgetBlueprint.h”
void UTSBBlueprintFunctionLibrary::StartWidget(UWidgetBlueprint* Blueprint)
{
if (Blueprint->GeneratedClass->IsChildOf(UEditorUtilityWidget::StaticClass()))
{
const UEditorUtilityWidget* CDO = Blueprint->GeneratedClass->GetDefaultObject();
if (CDO->ShouldAutoRunDefaultAction())
{
// This is an instant-run blueprint, just execute it
UEditorUtilityWidget* Instance = NewObject(GetTransientPackage(), Blueprint->GeneratedClass);
Instance->ExecuteDefaultAction();
}
else
{
FName RegistrationName = FName(*(Blueprint->GetPathName() + TEXT(“_ActiveTab”)));
FText DisplayName = FText::FromString(Blueprint->GetName());
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked(TEXT(“LevelEditor”));
TSharedPtr LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager();
TSharedRef NewDockTab = LevelEditorTabManager->InvokeTab(RegistrationName);
}
}
}
Hi First time comment, When I write this line:
const UeditorUtilityWidget* CDO = Blueprint->GeneratedClass->GetDefaultObject();
I get an error saying the a value of type UObject* cannot be used to initialize an entity of type const UEditorUtilityWidget*, shouldnt this be casted to the appropriate type?
Thank you
Also, New Object is a template class thus requires that you define the type, like this:
UEditorUtilityWidget* inst = NewObject(GetTransientPackage(), a_Blueprint->GeneratedClass);
Else I get an error.
I meant template function**
As of 4.23 they also made this possible without C++, you can auto-start a widget via ini file – see this thread: https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1661977-4-23-how-to-auto-start-editor-utility-widgets-new-feature
Thank you so much for this article. I was diving in the source code to do exactly this without any luck, but your article saved me!
inside your function,
auto EditorUIClass = LoadClass(nullptr, TEXT(“path to your widget_C”));
UWorld* World = GEditor->GetEditorWorldContext().World();
check(World);
UEditorUtilityWidget* CreatedUMGWidget = CreateWidget(World, EditorUIClass);
FVector2D Size = (400, 600); // set a window size to your widget
auto MyWindow = SNew(SWindow).ClientSize(Size).MaxHeight(600).MaxWidth(400);
MyWindow->SetContent(CreatedUMGWidget->TakeWidget());
FSlateApplication::Get().AddWindow(MyWindow, true);
Trying to 959betapplogin to this thing. Fingers crossed it recognizes my fingerprint. Hope it is easy to use! 959betapplogin
PPHWin, huh? Sounds promising! I’m always looking for good recommendations. What’s the verdict on this one, guys? I’ll be over here checking out pphwin.
Heard about 55666 bong88.net from a friend, and I was not disappointed. Registration was quick, and I was playing within minutes. Highly recommended for anyone looking for a new online option. 55666 bong88.net
CF Goldrush Gameclub? That’s my go-to for quick games after work. They’ve got new stuff coming out all the time, so it never gets boring. Come catch the gold: cf.goldrush.gameclub
I every time spent my half an hour to read this webpage’s articles every day along with a cup of coffee.
I enjoy what you guys tend to be up too. This type of clever work and exposure! Keep up the amazing works guys I’ve incorporated you guys to my own blogroll.
I am sure this article has touched all the internet users, its really really pleasant article on building up new website.
Enter to Pin-Up Casino and Unlock Big Rewards in Canada! ??
Are you excited to resume playing? With Pin-Up Casino, your next adventure is just a click away!
?? Why Log In to Pin-Up Casino?
Access Top-Quality Slots: From retro-style slots to modern video slots, your favorites are just a click away.
Exclusive Bonuses: Take advantage of regular promotions for returning players.
Safe & Secure: Your gaming data remains protected with advanced encryption systems.
Seamless Experience: With a mobile-friendly site, you can log in anytime, anywhere.
?? How to Log In
Logging in is quick and easy:
Visit the Website: Go to the official Pin-Up Casino page:
Pin-up account login
Enter Your Credentials: Input your registered information.
Click “Log In” to access your account and pick up where you left off.
Forgot Password? No problem! Reset your password in seconds and get back to playing.
? Experience the Thrill Every Time You Log In
With a vast selection of slots and table games, Pin-Up Casino ensures every login brings excitement, rewards, and the chance to win big.
?? Don’t Wait—Resume the Fun
Explore new slots at Pin-Up Casino, the ultimate destination for Canadian players.
Access Pin-Up Casino and Experience the Best in Online Gambling!
Hi, I log on to your blog daily. Your humoristic style is witty, keep up the good work!
Heya are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and create my own. Do you require any coding knowledge to make your own blog? Any help would be greatly appreciated!
pin-up online casino is a trusted casino platform for players from multiple regions. Here you can combine video slots and jackpots, live dealer tables and bets on popular events in one account.
At Pin Up Online everything is built for easy navigation and quick access. The official site at is designed for quick access, so you can create an account in a few steps and jump straight into your favorite slots and tables.
New players at this pinup casino online can unlock a first deposit offer that adds extra balance and often additional spins for popular slots. This allows you to get used to the interface without increasing your own risk too much. Just go to , complete the sign-up form, make a deposit and activate the promotion in the rewards area according to the rules.
The game selection at Pin Up real money site is built for different tastes, including:
– real money online slots with modern features and free spins.
– virtual table classics for fans of simple yet deep gameplay.
– studio-run casino games where professional dealers run the action in live HD format.
– In some regions, Pin Up sportsbook for those who like to bet on matches and tournaments.
This online casino Pin Up is optimized for phones, tablets and computers. You can open site from your smartphone and see the same cashier and bonuses in a layout that loads quickly even on mobile internet. It is convenient for quick spins during a break.
Banking at Pin Up real money platform is configured for international players. The cashier usually supports online payment systems so customers from multiple time zones can choose familiar systems. Information about payout rules is provided in the banking section, helping you plan your long-term gaming.
To reward active users, Pin Up Online Casino runs a range of extra deals for regulars. Players can find extra deposit deals, game-specific spins, rebate-style rewards and slot races with extra prizes. Many customers also join the tiered rewards system to unlock higher limits.
Getting started at this online casino Pin Up is simple: you visit
Pin Up online casino no download, click Sign Up, fill out the basic details, confirm your profile, then fund the account and choose any table game from the lobby.
Pinup online casino also highlights safe play. Users can usually set personal boundaries and should treat real money play as an additional activity. Only players who are 18+ should access this casino product.
If you are looking for a trusted iGaming brand where pin up online casino are at the center of the experience, you can start via LINK, create your account and explore fast games for different budgets from almost any country.
I just couldn’t leave your site prior to suggesting that I really loved the standard info a person supply for your guests? Is going to be again steadily in order to investigate cross-check new posts
I visited several blogs but the audio feature for audio songs current at this web site is really excellent.
Hi there, I read your blogs like every week. Your story-telling style is witty, keep doing what you’re doing!
Alright gamers. Quick tip: Check out s55game! You might find your jam here. Find your jam on s55game . This is exciting!
Hey guys! Checking out 999r and it seems pretty slick. Anyone else tried it out yet? Let me know what you think! Check it out here: 999r
Hey, just checked out 8143com and it’s pretty slick! A decent place to kick back and maybe get lucky. Worth a look definitely! 8143com
just wanted to say how much i appreciate your honest and down to earth writing style. it is so refreshing to read something that feels real and authentic in a world full of clickbait and fake news. u can tell u actually care about your readers and providing them with real value. thanks for being a breath of fresh air on the internet today i really enjoyed this one.
**aquasculpt**
aquasculpt is a premium metabolism-support supplement thoughtfully developed to help promote efficient fat utilization and steadier daily energy.
this was a very well written and informative article thanks for all the hard work u put into it. i love how u took a complex topic and made it so easy to understand for everyone regardless of their background. it is clear that u put a lot of time into making sure the info was accurate and easy to follow. thanks for the help as always u are a great resource!
Ahaa, its nice dialogue on the topic of this post at this place at this web site, I have read all that, so now me also commenting here.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.
office assistant training https://otvetnow.ru marin treatment center
https://askoff.ru