Class TypeConversion | Properties | 1.1.1-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class TypeConversion

    Helper class to handle type conversion during properties API calls.

    Inheritance
    Object
    TypeConversion
    Namespace: Unity.Properties
    Syntax
    public static class TypeConversion

    Methods

    Convert<TSource, TDestination>(TSource)

    Converts the specified value from TSource to TDestination.

    Declaration
    public static TDestination Convert<TSource, TDestination>(TSource value)
    Parameters
    Type Name Description
    TSource value

    The source value to convert.

    Returns
    Type Description
    TDestination

    The value converted to the TDestination type.

    Type Parameters
    Name Description
    TSource

    The source type to convert from.

    TDestination

    The destination type to convert to.

    Exceptions
    Type Condition
    InvalidOperationException

    No converter is registered for the given types.

    Register<TSource, TDestination>(ConvertDelegate<TSource, TDestination>)

    Registers a new converter from TSource to TDestination.

    Declaration
    public static void Register<TSource, TDestination>(ConvertDelegate<TSource, TDestination> convert)
    Parameters
    Type Name Description
    ConvertDelegate<TSource, TDestination> convert
    Type Parameters
    Name Description
    TSource
    TDestination

    TryConvert<TSource, TDestination>(TSource, out TDestination)

    Converts the specified value from TSource to TDestination.

    Declaration
    public static bool TryConvert<TSource, TDestination>(TSource source, out TDestination destination)
    Parameters
    Type Name Description
    TSource source

    The source value to convert.

    TDestination destination

    When this method returns, contains the converted destination value if the conversion succeeded; otherwise, default.

    Returns
    Type Description
    Boolean

    true if the conversion succeeded; otherwise, false.

    Type Parameters
    Name Description
    TSource

    The source type to convert from.

    TDestination

    The destination type to convert to.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023