UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FChange Class Referenceabstract

#include <Change.h>

+ Inheritance diagram for FChange:

Public Types

enum class  EChangeStyle { InPlaceSwap , CommandPattern }
 

Public Member Functions

virtual EChangeStyle GetChangeType ()=0
 
virtual TUniquePtr< FChangeExecute (UObject *Object)=0
 
virtual void Apply (UObject *Object)=0
 
virtual void Revert (UObject *Object)=0
 
virtual bool HasExpired (UObject *Object) const
 
virtual void AddReferencedObjects (FReferenceCollector &Collector)
 
virtual FString ToString () const =0
 
virtual CORE_API void PrintToLog (FFeedbackContext &FeedbackContext, const int32 IndentLevel=0)
 
virtual SIZE_T GetSize () const
 
virtual ~FChange ()
 

Protected Member Functions

 FChange ()
 

Detailed Description

FChange modifies a UObject and is meant to be used to implement undo/redo. The change is embedded in an FTransaction which executes it instead of the standard serialization transaction (cannot be combined - see FTransaction).

The original FChange style (used by MeshEditor) was that calling Execute() would return a new FChange that applies the opposite action, and FTransaction would swap the two at each undo/redo step (eg a "DeleteObject" FChange would return a "CreateObject" FChange)

The alternative "Command Pattern"-style FChange calls Apply() and Revert() on a single FChange.

FChange may eventually be deprecated. You should subclass FSwapChange and FCommandChange to implement these different styles.

Member Enumeration Documentation

◆ EChangeStyle

Enumerator
InPlaceSwap 
CommandPattern 

Constructor & Destructor Documentation

◆ ~FChange()

virtual FChange::~FChange ( )
inlinevirtual

Virtual destructor

◆ FChange()

FChange::FChange ( )
inlineprotected

Protected default constructor

Member Function Documentation

◆ AddReferencedObjects()

virtual void FChange::AddReferencedObjects ( FReferenceCollector Collector)
inlinevirtual

Used by GC to collect referenced objects.

◆ Apply()

◆ Execute()

virtual TUniquePtr< FChange > FChange::Execute ( UObject Object)
pure virtual

Makes the change to the object, returning a new change that can be used to perfectly roll back this change

Implemented in FCommandChange, and FCompoundChange.

◆ GetChangeType()

virtual EChangeStyle FChange::GetChangeType ( )
pure virtual

What style of change is this

Implemented in FSwapChange, and FCommandChange.

◆ GetSize()

virtual SIZE_T FChange::GetSize ( ) const
inlinevirtual

Gets the approximate number of bytes this change takes up in memory.

Used to

  • determine the size of transactions based on a custom change, e.g. when trimming the oldest transactions when the undo stack size is exceeded.
  • displaying the stack size, e.g. in the Undo Panel.

A typical implementation returns the size of any dynamically allocated memory, such GetAllocatedSize called on its containers (TArray, TSet, TMap). You should consider adding sizeof(FMyChange), if it's not insignificant. Remember: it's enough to return the approx. allocation size; it's unreasonable to expect every FChange implementation to return the exact amount, which also is not needed for the purpose of this function. Keep in mind, that for nested containers you need to call GetAllocatedSize recursively, e.g. for a "TArray<TArray<T>> Array" you'd need to return "Array.GetAllocatedSize() + Algo::Accumulate(Array, 0, [](const TArray<T>& A){ return A.GetAllocatedSize(); })".

This function is introduced in 5.7: too many FChange implementations exist so this function will need to be implemented gradually.

Returns
The approximate number of bytes this change takes up in memory.

◆ HasExpired()

virtual bool FChange::HasExpired ( UObject Object) const
inlinevirtual
Returns
true if this Change has Expired, ie it will no longer have any effect and could be skipped by undo/redo

Reimplemented in FBeginToolChange, FActivateToolChange, and FToolChangeWrapperChange.

◆ PrintToLog()

void FChange::PrintToLog ( FFeedbackContext FeedbackContext,
const int32  IndentLevel = 0 
)
virtual

Prints this change to the log, including sub-changes if there are any. For compound changes, there might be multiple lines. You should not need to override this function.

Reimplemented in FCompoundChange.

◆ Revert()

◆ ToString()


The documentation for this class was generated from the following files: