[ Web Proxy ]
URL:
Viewing: https://docs.unity3d.com/ScriptReference/PrefabUtility.GetNearestPrefabInstanceRoot.html [Back]  [Original]

Unity - Scripting API: PrefabUtility.GetNearestPrefabInstanceRoot
Version: Unity 6.5 (6000.5)
    • Supported
    • Legacy
    LanguageEnglish
    • C#

    PrefabUtility.GetNearestPrefabInstanceRoot

    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
    Your name Your email Suggestion* Submit suggestion

    Cancel

    Declaration

    public static GameObject GetNearestPrefabInstanceRoot(Object componentOrGameObject);

    Parameters

    Parameter Description
    componentOrGameObject The object to check. Must be a component or GameObject.

    Returns

    GameObject The nearest Prefab instance root.

    Description

    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.

    PrefabInstanceRoots.png [PrefabInstanceRoots.png]
    Overview of which objects are Prefab instance roots.

    In the editor, Prefab instance roots have Open and Select buttons, and in the case of an outermost Prefab instance root, an Overrides dropdown.

    Additional resources: GetOutermostPrefabInstanceRoot.


    Web Proxy Viewer  |  New URL  |  Original Page