RealDocs

AActor::PreSaveFromRoot

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

Description

Called on non-root actors in the same package before the root actor's package is saved. Gives nested actors a chance to prepare their state before serialization, similar to PreSaveRoot but for non-root objects.

Caveats & Gotchas

  • This is called in addition to (not instead of) PreSave — actors receive both callbacks during a save: PreSave for per-object prep and PreSaveFromRoot/PostSaveFromRoot for package-level coordination.
  • Always call Super::PreSaveFromRoot() to preserve engine bookkeeping; the base implementation may perform streaming-level adjustments.

Signature

ENGINE_API virtual void PreSaveFromRoot(FObjectPreSaveRootContext ObjectSaveContext);

Parameters

Name Type Description Default
ObjectSaveContext FObjectPreSaveRootContext Context for the save operation, including platform and cook target information.

Return Type

void

Example

Prepare a child actor before package save C++
void AMyChildActor::PreSaveFromRoot(FObjectPreSaveRootContext ObjectSaveContext)
{
	Super::PreSaveFromRoot(ObjectSaveContext);
	// Flush transient data that shouldn't be serialized
	RuntimeOnlyCache.Reset();
}

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.