Version: 2021.3

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