class
PrefabUtility
Performs various prefab specific operations.
Public
Methods
staticRevertToPrefab
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
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
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
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
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
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
Clears all prefab IDs in the provided object and its children (includes both the prefab object and prefab resource IDs).
staticGetInstanceToPrefabLinkInformationMap
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
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
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
Scans the provided hierarchy for any prefab instances, and updates them to the latest prefab data.
staticUpdateInstanceFromPrefab
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.