PrefabUtility.IsOutermostPrefabInstanceRoot

Switch to Manual
public static bool IsOutermostPrefabInstanceRoot (GameObject gameObject);

Parameters

gameObject要检查的游戏对象。

Returns

bool True if the GameObject is an outermost Prefab instance root.

Description

Is the GameObject the root of a Prefab instance, excluding nested Prefabs?

Returns true if the GameObject is the root GameObject of a Prefab instance, which is not itself inside another Prefab instance.

This also returns true for a the root GameObject of a nested Prefab instance inside a Prefab Asset, but not for a nested Prefab instance inside another Prefab instance inside a Prefab Asset.

If the GameObject is a Prefab instance root which is an added GameObject to another Prefab instance, it will return true, since it it not an the root of an applied nested Prefab instance.

The method will return 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.

In the editor, outermost Prefab instance roots have the Overrides dropdown, whereas other Prefab instance roots don’t.