Version: 2019.1

PrefabUtility.UnpackPrefabInstance

Switch to Manual
public static void UnpackPrefabInstance (GameObject root, PrefabUnpackMode unpackMode, InteractionMode action);

Parameters

instanceRootThe root of the Prefab instance to unpack.
unpackModeWhether to unpack the outermost root or unpack completely.
actionThe interaction mode to use for this action.

Description

Unpacks a given Prefab instance so that it is replaced with the contents of the Prefab Asset while retaining all override values.

The given object must be the root of a Prefab instance.

The contents of a Prefab Asset is the objects you see when you open it in Prefab Mode. Unpacking with a PrefabUnpackMode of OutermostRoot will replace the Prefab instance with that content. Unpacking with a PrefabUnpackMode of Completely will furthermore also unpack any Prefab instances that are part of the unpacked content, so that the end result is nothing but regular GameObjects and no Prefab instances.

The contents of a regular Prefab or a Model Prefab always has a regular GameObject at the root, so unpacking one of those will leave a regular GameObject at the root where the Prefab instance was before.

The contents of a Prefab Variant has an instance of the base Prefab at the root, so unpacking a Prefab Variant with a PrefabUnpackMode of OutermostRoot will leave an instance of the base Prefab where the Prefab Variant instance was before.

Unpacking throws an ArgumentException if the given object is not the root of a Prefab instance, or if it’s part of a Prefab Asset. This does not include Prefab contents opened i Prefab Mode.

InteractionMode determines if the action should be undoable.