Version: 2019.3
LanguageEnglish
  • C#

PrefabUtility.IsOutermostPrefabInstanceRoot

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static bool IsOutermostPrefabInstanceRoot(GameObject gameObject);

Parameters

gameObjectThe GameObject to check.

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 part of another Prefab instance.

This also returns true for outermost Prefab instance roots inside a Prefab Asset. Note that a Prefab Asset is not in itself a Prefab instance, but it may contain Prefab instances.

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

The method will return false if the given object is not part of a Prefab instance. This includes GameObjects that have been added and not applied to a Prefab instance.


Overview of which objects are Prefab instance roots.

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

See Also: IsAnyPrefabInstanceRoot.

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