NWH Common
Search Results for

    Show / Hide Table of Contents

    Class GameObjectExtensions

    Extension methods for GameObject and Transform operations.

    Inheritance
    object
    GameObjectExtensions
    Namespace: NWH.Common.Utility
    Assembly: NWH.Common.dll
    Syntax
    public static class GameObjectExtensions

    Methods

    | Edit this page View Source

    FindBoundsIncludeChildren(GameObject)

    Calculates the combined bounds of all MeshRenderers in a GameObject and its children.

    Declaration
    public static Bounds FindBoundsIncludeChildren(this GameObject gameObject)
    Parameters
    Type Name Description
    GameObject gameObject

    GameObject to calculate bounds for.

    Returns
    Type Description
    Bounds

    Combined bounds encapsulating all child renderers.

    | Edit this page View Source

    GetComponentInParent<T>(Transform, bool)

    Searches for a component in parent GameObjects, with option to include inactive objects. More flexible than Unity's built-in GetComponentInParent.

    Declaration
    public static T GetComponentInParent<T>(this Transform transform, bool includeInactive = true) where T : Component
    Parameters
    Type Name Description
    Transform transform

    Starting transform.

    bool includeInactive

    Include inactive GameObjects in search.

    Returns
    Type Description
    T

    First component of type T found in parents, or null if none found.

    Type Parameters
    Name Description
    T

    Type of component to find.

    | Edit this page View Source

    GetComponentInParentsOrChildren<T>(Transform, bool)

    Searches for a component in parents first, then children if not found. Combines functionality of GetComponentInParent and GetComponentInChildren.

    Declaration
    public static T GetComponentInParentsOrChildren<T>(this Transform transform, bool includeInactive = true) where T : Component
    Parameters
    Type Name Description
    Transform transform

    Starting transform.

    bool includeInactive

    Include inactive GameObjects in search.

    Returns
    Type Description
    T

    First component of type T found, or null if none found.

    Type Parameters
    Name Description
    T

    Type of component to find.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics