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.