Version: 2022.3
언어: 한국어

PrefabUtility.UnpackAllInstancesOfPrefab

매뉴얼로 전환
public static void UnpackAllInstancesOfPrefab (GameObject prefabRoot, PrefabUnpackMode unpackMode, InteractionMode action);

파라미터

prefabRoot The root GameObject of a Prefab Asset used to find all Prefab instances in open scenes that should be unpacked.
unpackMode Whether to unpack the outermost root or unpack completely.
action The interaction mode to use for this action.

설명

Unpacks all instances of a given Prefab Asset root GameObject in all open scenes so that all instances are replaced with the contents of the Prefab Asset while retaining all override values.

The Prefab instances will not be unpacked in closed scenes. This function uses PrefabUtility.FindAllInstancesOfPrefab to determine which instances to unpack and calls PrefabUtility.UnpackPrefabInstance for each instance.

Unpacking throws an ArgumentException if the given object is not the root GameObject of a Prefab Asset.

using UnityEditor;
using UnityEngine;

public class Example { public static void UnpackAllInstancesOfPrefab(string prefabPath) { var prefabAssetRoot = AssetDatabase.LoadMainAssetAtPath(prefabPath) as GameObject; if (prefabAssetRoot != null) { PrefabUtility.UnpackAllInstancesOfPrefab(prefabAssetRoot, PrefabUnpackMode.OutermostRoot, InteractionMode.UserAction); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961