class PrefabUtility

Performs various prefab specific operations.

Public

Methods

staticRevertToPrefab

static void RevertToPrefab(const HSceneObject &sceneObject)

Remove any instance specific changes to the object or its hierarchy from the provided prefab instance and restore it to the exact copy of the linked prefab.

staticUpdatePrefab

static void UpdatePrefab(const HPrefab &prefabToUpdate, const HSceneObject &sceneObjectToUpdateWith)

Updates the provided prefab resource so it stores a copy of the provided scene hierarchy.

Provided scene hierarchy is made to be an instance of the prefab, if not already an instance of the provided prefab, or any other prefab. All other currently loaded instances of will be updated to match the updated hierarchy.

Internal

Methods

staticAssignPrefabResourceId

static void AssignPrefabResourceId(const HSceneObject &sceneObject, const UUID &newPrefabResourceId)

Assigns the provided prefab resource ID to the provided scene object hierarchy recursively.

If a scene object that is part of another prefab is reached, iteration stops. Prefab instance IDs are assigned to their corresponding game object IDs (i.e. objects reference themselves).

staticAssignPrefabInstanceIds

static void AssignPrefabInstanceIds(const HSceneObject &instanceRoot, const HSceneObject &prefabRoot, const UUID &prefabResourceId)

Assigns prefab object and resource IDs to the provided scene object hierarchy.

The object IDs are retrieved from the provided

hierarchy, which must exactly match hierarchy (i.e. should be a clone of . All objects will be assigned as the prefab resource ID.

staticRemapPrefabInstanceIds

static void RemapPrefabInstanceIds(const HSceneObject &root, const UnorderedMap<UUID, UUID> &remappingTable, const UUID &prefabId)

Iterates the hierarchy in , and if a scene object or component is found in , assigns it the prefab object ID from the remapping table, and provided as the prefab resource ID.

staticRemapPrefabInstanceIds

static void RemapPrefabInstanceIds(const HSceneObject &root, const UnorderedMap<UUID, PrefabLinkInformation> &remappingTable)

Iterates the hierarchy in , and if a scene object or component is found in , assigns it the prefab object ID and prefab resource ID from the remapping table.

staticClearPrefabIds

static void ClearPrefabIds(const HSceneObject &sceneObject)

Clears all prefab IDs in the provided object and its children (includes both the prefab object and prefab resource IDs).

staticGetInstanceToPrefabLinkInformationMap

static UnorderedMap<UUID, PrefabLinkInformation> GetInstanceToPrefabLinkInformationMap(const HSceneObject &sceneObject, bool visitChildPrefabs)

Iterates over the provided scene object hierarchy and records a map of game object id -> { prefab object id, prefab resource id } for each scene object and component in the hierarchy.

sceneObject
Scene object at which to start iterating
visitChildPrefabs
If false, iteration into child scene objects will stop if they belong to another prefab. Otherwise we iterate until leaf of the hierarchy is reached.

Returns: Generated game object id -> { prefab object id, prefab resource id } map.

staticGetPrefabToInstanceIdMap

static UnorderedMap<UUID, UUID> GetPrefabToInstanceIdMap(const HSceneObject &sceneObject, bool visitChildPrefabs)

Iterates over the provided scene object hierarchy and records a map of prefab object id -> game object id for each scene object and component in the hierarchy.

sceneObject
Scene object at which to start iterating
visitChildPrefabs
If false, iteration into child scene objects will stop if they belong to another prefab. Otherwise we iterate until leaf of the hierarchy is reached.

Returns: Generated prefab object id -> game object id map.

Private

Methods

staticUpdateNestedPrefabInstances

static bool UpdateNestedPrefabInstances(const HSceneObject &sceneObject)

Scans the provided hierarchy for any prefab instances, loads their prefab resources and checks if prefab resources have any new changes since the instance was created.

If they do, the instance is updated with latest information from the prefab resource.

Returns true if any changes were made.

staticUpdateNestedPrefabInstancesRecursive

static bool UpdateNestedPrefabInstancesRecursive(const HSceneObject &root, PrefabCache &inOutPrefabCache)

Scans the provided hierarchy for any prefab instances, and updates them to the latest prefab data.

staticUpdateInstanceFromPrefab

static HSceneObject UpdateInstanceFromPrefab(const HSceneObject &instance, const Prefab &prefab)

Updates the provided scene object hierarchy with latest data from the provided prefab.

Provided scene object hierarchy must be a root object of an instance of the provided prefab. Returns null if nothing was updated.