docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GameObjectExtensions

    Extensions methods for the GameObject class.

    Inheritance
    object
    GameObjectExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CoreUtils
    Assembly: Unity.XR.CoreUtils.dll
    Syntax
    public static class GameObjectExtensions

    Methods

    AddToHideFlagsRecursively(GameObject, HideFlags)

    Adds hideFlags to the hide flags on this GameObject and all of its descendants.

    Declaration
    public static void AddToHideFlagsRecursively(this GameObject gameObject, HideFlags hideFlags)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject at the root of the hierarchy to be modified.

    HideFlags hideFlags

    Should the GameObjects be hidden, saved with the scene or modifiable by the user?

    Remarks

    This function combines the hideFlags with the existing flags of a GameObject.

    SetHideFlagsRecursively(GameObject, HideFlags)

    Sets the hide flags on this GameObject and all of its descendants.

    Declaration
    public static void SetHideFlagsRecursively(this GameObject gameObject, HideFlags hideFlags)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject at the root of the hierarchy to be modified.

    HideFlags hideFlags

    Should the GameObjects be hidden, saved with the scene, or modifiable by the user?

    Remarks

    This function overwrites the existing flags of a GameObject with those specified by hideFlags.

    SetLayerAndAddToHideFlagsRecursively(GameObject, int, HideFlags)

    Sets the layer of this GameObject and adds to its HideFlags, and does the same for all of its descendants.

    Declaration
    public static void SetLayerAndAddToHideFlagsRecursively(this GameObject gameObject, int layer, HideFlags hideFlags)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject at the root of the hierarchy to be modified.

    int layer

    The layer to recursively assign GameObjects to.

    HideFlags hideFlags

    Should the GameObjects be hidden, saved with the scene, or modifiable by the user?

    Remarks

    This function combines the hideFlags with the existing flags of a GameObject.

    SetLayerAndHideFlagsRecursively(GameObject, int, HideFlags)

    Sets the layer and HideFlags of this GameObject and all of its descendants.

    Declaration
    public static void SetLayerAndHideFlagsRecursively(this GameObject gameObject, int layer, HideFlags hideFlags)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject at the root of the hierarchy to be modified.

    int layer

    The layer to recursively assign GameObjects to.

    HideFlags hideFlags

    Should the GameObjects be hidden, saved with the scene, or modifiable by the user?

    Remarks

    This function overwrites the existing flags of a GameObject with those specified by hideFlags.

    SetLayerRecursively(GameObject, int)

    Sets the layer of this GameObject and all of its descendants.

    Declaration
    public static void SetLayerRecursively(this GameObject gameObject, int layer)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject at the root of the hierarchy to be modified.

    int layer

    The layer to recursively assign GameObjects to.

    SetRunInEditModeRecursively(GameObject, bool)

    Sets runInEditMode for all MonoBehaviours on this GameObject and its children.

    Declaration
    public static void SetRunInEditModeRecursively(this GameObject gameObject, bool enabled)
    Parameters
    Type Name Description
    GameObject gameObject

    The GameObject at the root of the hierarchy to be modified.

    bool enabled

    The value to assign to runInEditMode.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)