Hello, I am fairly new to editor scripting in unreal and I want to implement undo/redo functionality for my EditorUtilityWidget.
Inside my widget i frequently spawn custom UserWidgets, for example as editable nodes.
I want to track everything the user can do with transactions.
But when i spawn widgets and call undo, the widgets references all disappear, but they are still displayed in the editor window, with all interaction gone.
One of my Spawns looks like this:
UMissionEditor_MissionNode* UMissionEditor_Window::SpawnNode_Internal(
const TSubclassOf<UMissionEditor_MissionNode> WidgetClass)
{
if(!Mission || !WidgetClass || !NodesCanvas)
return nullptr;
FScopedTransaction Transaction(FText::FromString("Spawn Editor Node"));
UMissionEditor_MissionNode* NewWidget = WidgetTree->ConstructWidget<UMissionEditor_MissionNode>(WidgetClass);
NewWidget->Modify();
NodesCanvas->Modify();
NodesCanvas->AddChild(NewWidget);
Cast<UCanvasPanelSlot>(NewWidget->Slot)->SetPosition(LocalMousePos - Cast<UCanvasPanelSlot>(NodesCanvas->Slot)->GetPosition());
NewWidget->OnMouseEvent.BindDynamic(this, &UMissionEditor_Window::UMissionEditor_Window::OnMouseMoveEvent);
NewWidget->SetID(Mission->IDCounter++);
return NewWidget;
}
I have tried with and without the Modify and everything else i could find about transactions.
Is there something i am missing or do transactions just not handle widget spawning well?