Not sure what I’m doing wrong here. I’m creating a custom module-based editor for a class, and I’m trying to add undo and redo support for adding and removing modules.
Here’s an example of what I’m doing:
Code:
// Create an Undoable Transaction
{
FScopedTransaction Trans = FScopedTransaction(LOCTEXT("CreateOrdModule_Transaction", "Create Module"));
CurrentTemplate->Modify();
// Notify Template
CurrentTemplate->PreEditChange(nullptr);
// Construct Module and add to selected emitter
UST_OrdnanceModule* NewModule = NewObject<UST_OrdnanceModule>(CurrentTemplate, NewModuleClass, NAME_None, RF_Transactional);
NewModule->Modify();
NewModule->SetToSensibleDefaults();
NewModule->SetTransactionFlag();
CurrentTemplate->OrdnanceModules.Add(NewModule);
CurrentTemplate->OnModulesUpdated();
CurrentTemplate->PostEditChange();
ForceRefresh();
}
But if I call Undo after running this transaction, the module is NOT removed from the array. The Array is a UPROPERTY with no extra meta data.
What am I doing wrong here?