RealDocs

AActor::PreSaveRoot

function Engine Since 5.1
#include "GameFramework/Actor.h"
Access: public Specifiers: virtualoverride

Description

Called before the root object of a package is saved. Override to perform actor-level pre-save work that should happen once per package save, as opposed to per-object (PreSave).

Caveats & Gotchas

  • Always call Super::PreSaveRoot() — the base implementation handles level streaming data and other engine bookkeeping that must run before save.
  • This fires once per package root save, not once per actor in the package. For per-object pre-save logic, override PreSave instead.
  • Avoid spawning or destroying actors inside this callback; the world may be in an inconsistent state during package serialization.

Signature

ENGINE_API virtual void PreSaveRoot(FObjectPreSaveRootContext ObjectSaveContext) override;

Parameters

Name Type Description Default
ObjectSaveContext FObjectPreSaveRootContext Context describing the save operation, including whether it is a cook or editor save.

Return Type

void

Example

Pre-save cleanup on the package root actor C++
void AMyActor::PreSaveRoot(FObjectPreSaveRootContext ObjectSaveContext)
{
	Super::PreSaveRoot(ObjectSaveContext);
	// Flush any transient cached data before the package is written to disk
	TransientCache.Empty();
}

Version History

Introduced in: 5.1

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.