unreal.LevelStreamingPersistenceManager

class unreal.LevelStreamingPersistenceManager(outer: Object | None = None, name: Name | str = 'None')

Bases: WorldSubsystem

Level Streaming Persistence Manager

C++ Source:

  • Plugin: LevelStreamingPersistence

  • Module: LevelStreamingPersistence

  • File: LevelStreamingPersistenceManager.h

eject_placed_actor(actor) bool

Ejects a map-placed actor: it will be absent on next level reload, but stay alive for the current session. The actor class must be eligible for persistent destruction, see Level Streaming Persistence Settings. Use cases: treat the actor as destroyed while it’s alive for animation purposes.

The actor becomes eligible for runtime respawning if it passes your other checks, i.e. RuntimeRespawnedActorClasses and OnShouldPersistRuntimeActor. For handing over an actor for runtime respawning, also see RecreateActorInLevel and RecreateActorInPersistentLevel.

Parameters:

actor (Actor)

Return type:

bool

initialize_from(payload) bool

Deserialize the persistent properties of all streaming levels of the current map from byte array. The payload should be from an earlier SerializeTo call, from an earlier play session of the same map. Call this only once per map.

It’s recommended to call this from a custom UWorldSubsystem::Initialize, early enough to restore properties on persistent level actors before they BeginPlay, and before initial streaming levels are made visible. You can also call this post-begin play, which is useful for blueprint only projects. Calling this post-begin play will overwrite properties on actors that have begun play. Currently, only native callbacks are provided: PostRestoreObject and PostRestoreLevel.

Parameters:

payload (Array[uint8]) – Byte array containing saved values for all streaming levels of the current map, and persistent level if enabled. Should be from an earlier SerializeTo call, from the same map but earlier play session.

Returns:

Whether deserialization succeeded

Return type:

bool

recreate_actor_in_level(actor, new_owning_level) Actor

Captures persistent values for the actor, destroys it and respawns it into another level. Converting a map-placed actor into a runtime respawned one lets it cross boundaries. Deciding the correct method to mitigate visual pop, and restoring references, is left up to the callee. If the actor is map-placed, its class must be configured for persistent destruction. The actor class must be configured to be respawnable.

In specific cases such as world already in tear-down, the respawning of the actor may fail while the original actor is still destroyed.

Parameters:
Return type:

Actor

recreate_actor_in_persistent_level(actor) Actor

Calls RecreateActorInLevel passing the persistent level. Used for blueprint exposing the common route of moving an actor to the persistent level. If the actor is map-placed, its class must be configured for persistent destruction.

In specific cases such as world already in tear-down, the respawning of the actor may fail while the original actor is still destroyed.

Parameters:

actor (Actor)

Return type:

Actor

serialize_to(force_update=False) Array[uint8] or None

Serialize the persistent properties of all streaming levels of the current map to byte array. This can be put in a SaveGame’s property to save to file.

Parameters:

force_update (bool) – If true, will iterate all visible streaming levels to update their persistence data. Recommended for saving latest world snapshot.

Returns:

out_payload (Array[uint8]): Byte array containing saved values for all streaming levels of the current map, and persistent level if enabled.

Return type:

Array[uint8] or None