# Very quick rundown of Editor Undo System?

**URL:** <https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [March 27, 2014, 1:07pm UTC](https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656 "2014-03-27T13:07:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 27, 2014, 1:07pm UTC](https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656/1 "2014-03-27T13:07:26Z")

</div>

Dear Friends at Epic,

Any chance of a very short rundown of all steps to work with undo system in the editor?

I got this far

I run this upon selecting new actor

```
//Set Transactonal
VictoryEngine->VSelectedActor->SetFlags(RF_Transactional);

```

I am running this each time a vertex snap / editor action occrs

```
void DoSnap()
{
    const FScopedTransaction Transaction( TEXT("Snap"), LOCTEXT( "VictoryEditor", "Vertex Snap" ), VictoryEngine->VSelectedActor );
    
    VictoryEngine->VSelectedActor->Modify();

    //I then do the vertex snap here, and end the local context / scope
    VictoryEngine->VSelectedActor->SetActorLocation(...);
}

```

…

And that’s all I know so far!

The issue I have is that sometimes the above works, but others time the chain of undo/redo is broken,

Are there additional steps to play nice with the existing undo/redo system?

#Thanks!

Rama

---

<div class="post-metadata">

**Author:** ![Marc\_Audy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marc_audy/32/710746_2.png) [@Marc\_Audy](https://forums.unrealengine.com/u/Marc_Audy)\
**Post date:** [March 27, 2014, 1:56pm UTC](https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656/2 "2014-03-27T13:56:25Z")

</div>

You seem to have gotten the majority of it worked out, my guess is that your issue is that every object that has properties modified as part of the transaction needs to have modify called on it. In the case of SetActorLocation that means that properties will be set on the RootComponent and there isn’t an internal Modify call made on the component (possibly questionable that there isn’t, but it is what it is), so you need to do one yourself.

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [March 27, 2014, 2:23pm UTC](https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656/3 "2014-03-27T14:23:43Z")

</div>

It’s also worth noting that transactions are only saved when the outermost transaction is closed.

That means if you open a scoped transaction in FuncA and call FuncB that also opens a scoped transaction, you won’t see the transaction from FuncB as a separate undo, as it will be merged into the undo opened for FuncA.

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [March 27, 2014, 9:53pm UTC](https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656/4 "2014-03-27T21:53:49Z")

</div>

![2538-undo.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/6/d26867cbe20a828f760f1367da3c03421b6a0e05.jpeg)

#Thank You Marc Audy!

That did it!!!

I dont know how long it would have taken me to figure that out on my own

My Vertex Snap Editor Plugin now fully supports the UE4 Undo system, thanks to you!

#Plugin Link With Entire Source Code

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

#Thank You Jamie!

And thank you Jamie for being so prompt in answering my questions ❤!

![2537-rainbow.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/4/674bf3af67a4e578d2f06f299028ffb6d594119d.jpeg)

#Code Sample for Others

#.cpp

```
#include "ScopedTransaction.h"
#define LOCTEXT_NAMESPACE "VictoryVertexSnapEditor"

//Save an Undo, must target the components directly

//this is after a SetActorLocation() has occurred
//TheActor->SetActorLocation();

const FScopedTransaction Transaction( TEXT("Snap"), LOCTEXT( "VictoryGame", "Victory Vertex Snap" ), TheActor->GetRootComponent() );
TheActor->GetRootComponent()->Modify();
```

---

<div class="post-metadata">

**Author:** ![scamp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@scamp](https://forums.unrealengine.com/u/scamp)\
**Post date:** [April 21, 2016, 9:45pm UTC](https://forums.unrealengine.com/t/very-quick-rundown-of-editor-undo-system/278656/5 "2016-04-21T21:45:30Z")

</div>

For other folks, now-a-days (4.10) the preferred method is to use the 2 parameter constructor version for FScopedTransaction (second param has default value and isn’t required) rather than the 4 param version e.g.:

```
    const FScopedTransaction Transaction(LOCTEXT("Text1", "Text2"));
    TheActor->GetRootComponent()->Modify();

```

and make sure to called Modify() before actually modifying the object, which is what takes the snapshot
