Hello!
I have a simple Editor Utility Widget called LoaderNameEnter:
UCLASS()
class ULoaderNameEnter : public UEditorUtilityWidget
{
GENERATED_BODY()
public:
virtual void NativeConstruct() override;
virtual FReply NativeOnKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent) override;
UFUNCTION()
void NameExists();
UFUNCTION()
void NameDoesNotExist();
private:
UFUNCTION()
void OnTextBoxTextCommited(const FText& Text, ETextCommit::Type CommitMethod);
UFUNCTION()
void OnTextBoxTextChanged(const FText& Text);
public:
UPROPERTY()
FLoaderNameEntered LoaderNameEntered;
UPROPERTY()
FLoaderNameChanged LoaderNameChanged;
protected:
UPROPERTY(EditAnywhere, meta = (BindWidget))
class UEditorUtilityEditableTextBox* TextBox;
UPROPERTY(EditAnywhere, meta = (BindWidget))
class UTextBlock* BadNameLabel;
private:
bool safe_to_create = false;
};
I also have an editor subsystem InteractableSpawnerSubsystem which, when new actor is dropped into the level, checks if this actor has specified Interface, and if it does – spawns LoaderNameEnter Editor Widget so I can enter it’s name for generating some stuff.
void UInteractableSpawnerSubsystem::Initialize(FSubsystemCollectionBase& Collection) {
Collection.InitializeDependency(UEditorActorSubsystem::StaticClass());
UE_LOGFMT(InteractableSpawnerSubsystem, Log, "Initialised interactable spawner subsystem");
UEditorActorSubsystem* editor_actor_subsystem = GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
editor_actor_subsystem->OnNewActorsDropped.AddUniqueDynamic(this, &UInteractableSpawnerSubsystem::OnInteractableActorDropped);
LoaderNameEdtiorBleuprint = UEditorAssetLibrary::LoadAsset(FString(TEXT("/Script/Blutility.EditorUtilityWidgetBlueprint'/Game/Blueprints/UI/Editor/BP_LoaderNameEnter1.BP_LoaderNameEnter1'")));
}
void UInteractableSpawnerSubsystem::Deinitialize(){
Super::Deinitialize();
}
void UInteractableSpawnerSubsystem::OnInteractableActorDropped(const TArray<UObject*>& DroppedObjects, const TArray<AActor*>& DroppedActors){
UE_LOGFMT(InteractableSpawnerSubsystem, Log, "Firing due to actor dropped");
if (DroppedActors.Num() == 1) {
IInteractable* interactable = Cast<IInteractable>(DroppedActors[0]);
if (interactable) {
if (IsValid(LoaderNameEdtiorBleuprint)) {
LoaderNameEditorBlueprint = Cast<UEditorUtilityWidgetBlueprint>(LoaderNameEdtiorBleuprint);
if (IsValid(LoaderNameEditorBlueprint)) {
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
EditorUtilitySubsystem->SpawnAndRegisterTab(LoaderNameEditorBlueprint);
LoaderNameEditor = Cast<ULoaderNameEnter>(LoaderNameEditorBlueprint->GetCreatedWidget());
if (LoaderNameEditor) {
LoaderNameEditor->LoaderNameEntered.AddUniqueDynamic(this, &UInteractableSpawnerSubsystem::CreateInteractableConfigs);
LoaderNameEditor->LoaderNameChanged.AddUniqueDynamic(this, &UInteractableSpawnerSubsystem::CheckActorName);
}
}
}
}
}
//GEditor->Exec(GetWorld(), TEXT("py test.py")); //todo -- create python bridge?
}
void UInteractableSpawnerSubsystem::CreateInteractableConfigs(const FString& name){
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
EditorUtilitySubsystem->UnregisterTabByID(LoaderNameEditorBlueprint->GetRegistrationName());
if (!Helper) {
//LevelIndex = CreateDefaultSubobject<ULevelIndex>(TEXT("Level Index"));
Helper = UPythonEditorHelper::Get();
//TODO -- inits
TArray<FString> levels = Helper->GetLevelIndex();
//LevelIndex->BuildIndex(levels);
UE_LOGFMT(InteractableSpawnerSubsystem, Log, "Index has level {0}", levels[0]);
}
if (Helper) {
Helper->CreateInteractableConfigs(FString());
}
}
void UInteractableSpawnerSubsystem::CheckActorName(const FString& Name){
bool name_free = fmod(Name.Len(), 2) == 0; //todo -- run script for checking if exist
//there may be a probl
// em if we type to fast and script is too slow -- build index of those files here?
if (name_free) {
LoaderNameEditor->NameDoesNotExist();
}
else {
LoaderNameEditor->NameExists();
}
}
Now, at first it all worked without problems. However, when I closed unreal editor and then opened it my widget seemed to be borked – when I drop in another actor with given interface editor freezes for a second and spawns me an empty widget. Here is log I get when i try to spawn it:
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: === Handled ensure: ===
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: Ensure condition failed: InWidgetTree [File:D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\UserWidget.cpp] [Line: 199]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: Stack:
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00007ffcad8cc8ce UnrealEditor-UMG.dll!UUserWidget::DuplicateAndInitializeFromWidgetTree() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\UserWidget.cpp:199]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00007ffcad8d971d UnrealEditor-UMG.dll!UWidgetBlueprintGeneratedClass::InitializeWidgetStatic() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\WidgetBlueprintGeneratedClass.cpp:226]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00007ffcad8d936b UnrealEditor-UMG.dll!UWidgetBlueprintGeneratedClass::InitializeWidget() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\WidgetBlueprintGeneratedClass.cpp:342]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00007ffcad8d80b4 UnrealEditor-UMG.dll!UUserWidget::Initialize() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\UserWidget.cpp:140]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00007ffcad8c7226 UnrealEditor-UMG.dll!UUserWidget::CreateInstanceInternal() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\UserWidget.cpp:2463]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00007ffcad8c838e UnrealEditor-UMG.dll!UUserWidget::CreateWidgetInstance() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\UserWidget.cpp:2418]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00000206081b8c29 UnrealEditor-Blutility.dll!CreateWidget<UEditorUtilityWidget,UWorld * __ptr64>() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Public\Blueprint\UserWidget.h:1708]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x00000206081fec4a UnrealEditor-Blutility.dll!UEditorUtilityWidgetBlueprint::CreateUtilityWidget() [D:\build\++UE5\Sync\Engine\Source\Editor\Blutility\Private\EditorUtilityWidgetBlueprint.cpp:100]
[2025.02.23-22.55.58:488][404]LogOutputDevice: Error: [Callstack] 0x0000020608225450 UnrealEditor-Blutility.dll!UEditorUtilityWidgetBlueprint::SpawnEditorUITab() [D:\build\++UE5\Sync\Engine\Source\Editor\Blutility\Private\EditorUtilityWidgetBlueprint.cpp:71]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x0000020608202a51 UnrealEditor-Blutility.dll!V::TBaseUObjectMethodDelegateInstance::Execute() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:650]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb50036c0 UnrealEditor-Slate.dll!FTabManager::SpawnTab() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Docking\TabManager.cpp:2043]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb4fb7ed8 UnrealEditor-Slate.dll!FTabManager::InvokeTab_Internal() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Docking\TabManager.cpp:1438]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb50091ce UnrealEditor-Slate.dll!FTabManager::TryInvokeTab() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Docking\TabManager.cpp:1357]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x0000020608225d9a UnrealEditor-Blutility.dll!UEditorUtilitySubsystem::SpawnRegisteredTabByID() [D:\build\++UE5\Sync\Engine\Source\Editor\Blutility\Private\EditorUtilitySubsystem.cpp:353]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x0000020608224c7c UnrealEditor-Blutility.dll!UEditorUtilitySubsystem::SpawnAndRegisterTab() [D:\build\++UE5\Sync\Engine\Source\Editor\Blutility\Private\EditorUtilitySubsystem.cpp:245]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffc5f1b6147 UnrealEditor-pr-0462.dll!UInteractableSpawnerSubsystem::OnInteractableActorDropped() [D:\unreal_projects\pr\Source\pr\Private\Editor\InteractableSpawnerSubsystem.cpp:37]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffc5f185b0c UnrealEditor-pr-0462.dll!UInteractableSpawnerSubsystem::execOnInteractableActorDropped() [D:\unreal_projects\pr\Intermediate\Build\Win64\UnrealEditor\Inc\prf\UHT\InteractableSpawnerSubsystem.gen.cpp:169]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb57404c2 UnrealEditor-CoreUObject.dll!UFunction::Invoke() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:6847]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb5aa9■■■ UnrealEditor-CoreUObject.dll!UObject::ProcessEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2144]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffca61cb9a3 UnrealEditor-UnrealEd.dll!TMulticastScriptDelegate<FNotThreadSafeDelegateMode>::ProcessMulticastDelegate<UObject>() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\UObject\ScriptDelegates.h:917]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffca61cfe11 UnrealEditor-UnrealEd.dll!FOnEditNewActorsDropped_DelegateWrapper() [D:\build\++UE5\Sync\Engine\Intermediate\Build\Win64\UnrealEditor\Inc\UnrealEd\UHT\EditorActorSubsystem.gen.cpp:100]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffca7415537 UnrealEditor-UnrealEd.dll!TBaseUObjectMethodDelegateInstance<0,UEditorActorSubsystem,void __cdecl(TArray<UObject *,TSizedDefaultAllocator<32> > const &,TArray<AActor *,TSizedDefaultAllocator<32> > const &),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:667]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffca6fb6764 UnrealEditor-UnrealEd.dll!FLevelEditorViewportClient::DropObjectsAtCoordinates() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\LevelEditorViewport.cpp:2139]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffca1d17556 UnrealEditor-LevelEditor.dll!SLevelViewport::HandlePlaceDraggedObjects() [D:\build\++UE5\Sync\Engine\Source\Editor\LevelEditor\Private\SLevelViewport.cpp:1067]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffca1d2e62b UnrealEditor-LevelEditor.dll!SLevelViewport::OnDrop() [D:\build\++UE5\Sync\Engine\Source\Editor\LevelEditor\Private\SLevelViewport.cpp:1146]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb4ed9e79 UnrealEditor-Slate.dll!`SharedPointerInternals::TReferenceControllerBase<1>::ReleaseSharedReference'::`5'::<lambda_1>::operator()() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:5335]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb4ec225f UnrealEditor-Slate.dll!TArray<TSharedRef<SWindow,1>,TSizedDefaultAllocator<32> >::RemoveAll<`TArray<TSharedRef<SWindow,1>,TSizedDefaultAllocator<32> >::Remove'::`2'::<lambda_1> >() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:442]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb4f2137e UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:5330]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb4f0e8f1 UnrealEditor-Slate.dll!FSlateApplication::ProcessMouseButtonUpEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:5857]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcb4f01aa6 UnrealEditor-Slate.dll!FSlateApplication::OnMouseUp() [D:\build\++UE5\Sync\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp:5813]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcba5dd54f UnrealEditor-ApplicationCore.dll!FWindowsApplication::ProcessDeferredMessage() [D:\build\++UE5\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:2243]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcba5c6f16 UnrealEditor-ApplicationCore.dll!FWindowsApplication::DeferMessage() [D:\build\++UE5\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:2750]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcba5dff93 UnrealEditor-ApplicationCore.dll!FWindowsApplication::ProcessMessage() [D:\build\++UE5\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:1919]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcba5c0e51 UnrealEditor-ApplicationCore.dll!FWindowsApplication::AppWndProc() [D:\build\++UE5\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsApplication.cpp:929]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffd2ff98211 USER32.dll!UnknownFunction []
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffd2ff97cd1 USER32.dll!UnknownFunction []
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffcba5e0a96 UnrealEditor-ApplicationCore.dll!FWindowsPlatformApplicationMisc::PumpMessages() [D:\build\++UE5\Sync\Engine\Source\Runtime\ApplicationCore\Private\Windows\WindowsPlatformApplicationMisc.cpp:145]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ff69693780a UnrealEditor.exe!FEngineLoop::Tick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5850]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ff69695e33c UnrealEditor.exe!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:180]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ff69695e42a UnrealEditor.exe!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ff6969618a4 UnrealEditor.exe!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ff6969770c4 UnrealEditor.exe!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ff69697a37a UnrealEditor.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffd2fc326ad KERNEL32.DLL!UnknownFunction []
[2025.02.23-22.55.58:489][404]LogOutputDevice: Error: [Callstack] 0x00007ffd3166aa68 ntdll.dll!UnknownFunction []
What am I doing wrong here?