PrefabUtility.ApplyPrefabInstance

Cambiar al Manual
public static void ApplyPrefabInstance (GameObject instanceRoot, InteractionMode action);

Parámetros

instanceRootThe root of the given Prefab instance.
actionThe interaction mode for this action.

Descripción

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.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961