Version: 2022.3
LanguageEnglish
  • C#
Method group is Obsolete

PrefabUtility.FindPrefabRoot

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

Obsolete Use GetOutermostPrefabInstanceRoot if source is a Prefab instance or source.transform.root.gameObject if source is a Prefab Asset object.

Declaration

public static GameObject FindPrefabRoot(GameObject source);

Parameters

source The object to check.

Returns

GameObject The Prefab root.

Description

Retrieves the root GameObject of the Prefab that the supplied GameObject is part of.

This method checks if the object is part of a Prefab (either a Prefab instance or a Prefab Asset) and if so, returns the root GameObject of the Prefab.

This method is used internally in the Editor to help the user select the correct object when GameObjects are clicked in the Scene view.