docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method TryConstructTypeDerivedFrom

    TryConstructTypeDerivedFrom<T>(out T)

    Construct instance of first type derived from T. Derived type must have an implicit, default or registered constructor.

    Declaration
    public static bool TryConstructTypeDerivedFrom<T>(out T value)
    Parameters
    Type Name Description
    T value

    New instance of derived type.

    Returns
    Type Description
    bool

    true if new instance was successfully constructed, false otherwise.

    Type Parameters
    Name Description
    T

    The derived type.

    TryConstructTypeDerivedFrom<T>(Func<Type, bool>, out T)

    Construct instance of first type derived from T that satisfies the filtering function. Derived type must have an implicit, default or registered constructor.

    Declaration
    public static bool TryConstructTypeDerivedFrom<T>(Func<Type, bool> filter, out T value)
    Parameters
    Type Name Description
    Func<Type, bool> filter

    The filtering function.

    T value

    New instance of derived type.

    Returns
    Type Description
    bool

    true if new instance was successfully constructed, false otherwise.

    Type Parameters
    Name Description
    T

    The derived type.

    TryConstructTypeDerivedFrom<T>(Func<T, bool>, out T)

    Construct instance of first type derived from T that satisfies the condition function. Derived type must have an implicit, default or registered constructor.

    Declaration
    public static bool TryConstructTypeDerivedFrom<T>(Func<T, bool> condition, out T value)
    Parameters
    Type Name Description
    Func<T, bool> condition

    The condition function.

    T value

    New instance of derived type.

    Returns
    Type Description
    bool

    true if new instance was successfully constructed, false otherwise.

    Type Parameters
    Name Description
    T

    The derived type.

    TryConstructTypeDerivedFrom<T>(Func<Type, bool>, Func<T, bool>, out T)

    Construct instance of first type derived from T that satisfies both the filtering and condition functions. Derived type must have an implicit, default or registered constructor.

    Declaration
    public static bool TryConstructTypeDerivedFrom<T>(Func<Type, bool> filter, Func<T, bool> condition, out T value)
    Parameters
    Type Name Description
    Func<Type, bool> filter

    The filtering function.

    Func<T, bool> condition

    The condition function.

    T value

    New instance of derived type.

    Returns
    Type Description
    bool

    true if new instance was successfully constructed, false otherwise.

    Type Parameters
    Name Description
    T

    The derived type.

    In This Article
    Back to top
    Copyright © 2024 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)