Version: 2021.2

PrefabUtility.GetNearestPrefabInstanceRoot

切换到手册
public static GameObject GetNearestPrefabInstanceRoot (Object componentOrGameObject);

参数

componentOrGameObject 要检查的对象。必须是组件或游戏对象。

返回

GameObject 最近的预制件实例根。

描述

Retrieves the GameObject that is the root of the nearest Prefab instance the object is part of.

The method searches the Transform hierarchy until it finds the root of any Prefab instance, regardless of whether that instance is an applied nested Prefab inside another Prefab, or not.

The method returns null if the given object is not part of a Prefab instance. This includes GameObjects or components that have been added and not applied to a Prefab instance.


哪些对象是预制件实例根的概述。

在编辑器中,预制件实例根具有 Open 和 Select 按钮,若是最外面的预制件实例根,则具有 Overrides 下拉选单。

另请参阅:GetOutermostPrefabInstanceRoot

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