Version: 2021.2
언어: 한국어

PrefabUtility.ApplyPrefabInstance

매뉴얼로 전환
public static void ApplyPrefabInstance (GameObject instanceRoot, InteractionMode action);

파라미터

instanceRoot The root of the given Prefab instance.
action The interaction mode for this action.

설명

Applies all overrides on a Prefab instance to its Prefab Asset.

This method allows you to apply the complete modified state of a Prefab instance to its soruce Prefab Asset, which includes all property overrides, added and removed components, and added child GameObjects (including added child Prefab instances).

It mirrors the functionality of the "Apply All" button in the overrides menu in the editor. To use this method, you must first modify an existing Prefab instance in some way, such as modifying properties, or adding or removing GameObjects or components.

Modifications to a Prefab instance that have not been applied are called instance overrides. The act of applying the modifications means the modifications become part of the Prefab Asset, and are no longer overrides.

When applying all modifications to a Prefab Asset using this method to nested Prefabs or Prefab variants, the changes are always applied to the outermost Prefab. To apply changes to inner Prefabs, you can use the other methods such as PrefabUtility.ApplyAddedComponent, PrefabUtility.ApplyAddedGameObject, PrefabUtility.ApplyRemovedComponent and PrefabUtility.ApplyObjectOverride.

The Transform position and rotation of a root GameObject in a Prefab instance cannot be applied, nor can other default override properties.

You can read more in the user manual about modifying and applying changes to Prefab instances.

See Also: PrefabUtility.ApplyAddedComponent, PrefabUtility.ApplyAddedGameObject, PrefabUtility.ApplyObjectOverride, PrefabUtility.ApplyPropertyOverride, PrefabUtility.ApplyRemovedComponent.