Use UMG to extend an FModeToolkit?

I have a custom FModeToolkit, I would like to extend it with UMG (ultimately with Unreal.js, but it should work with Blueprints).

How can I do it?

I try to add a UWidget to this custom FModeToolkit, and to expose it to the Blueprint world:

CustomEdModeToolkit.cpp:

FCustomEdModeToolkit::FProBuilderEdModeToolkit()
{
        // Create the UWidget
	WidgetInstance = CreateWidget<UWidget>(GEditor->GetWorld(), WidgetTemplate);

       // Use it in slate (how??)
	SAssignNew(ToolkitWidget, SBorder)     // ToolkitWidget is an SWidget
	[
		SNew(SScrollBox)
		+ SScrollBox::Slot()
		.Padding(10.0f)
		[
			WidgetInstance->TakeWidget() // like this?
		]
	];

       // Expose it to Blueprint, ToolkitWidget is a UProperty of a Blueprintable class:
       BlueprintableClass->ToolkitWidget = WidgetInstance;
}

BlueprintableClass.h:

UCLASS(Blueprintable, BlueprintType)
class ABlueprintableClass : public AActor
{
	GENERATED_BODY()
	
public:
	ABlueprintableClass ();
	UPROPERTY(BlueprintReadWrite)
	UWidget* ToolkitWidget;
};

But it crashed when I do WidgetInstance->TakeWidget(), WidgetInstance does not seem to be properly instanciated.

The question on gamedev.stackexchange.com

Actually you can use UMG to extend your editor. Unreal.js lets you can do so with Javascript! :slight_smile: GitHub - ncsoft/Unreal.js: Unreal.js: Javascript runtime built for UnrealEngine

UMG generated slate widget needs its parent UMG instance to work properly, but UMG widget can be GC’d at any time to cause a crash. So you should maintain proper reference to those UMG instances not to be GC’d.

:slight_smile:

Thanks! I’m sorry, I don’t see how to extend the Toolkit with UMG in js… I probably need a reference to my toolkit slate widget on the JS side.