docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method Duplicate

    Duplicate(in T, ref T)

    Duplicates a value using the most efficient means of creating a complete copy. For most types this is a simple assignment or memcpy. For managed types, this is will serialize and then deserialize the value to ensure a correct copy.

    Note: If you are using this in a custom generic class, please make sure your class is decorated with GenerateSerializationForGenericParameterAttribute so that codegen can initialize the serialization mechanisms correctly. If your class is NOT generic, it is better to duplicate it directly.

    If the codegen is unable to determine a serializer for a type, UserNetworkVariableSerialization<T>.DuplicateValue is called, which, by default, will throw an exception, unless you have assigned a user duplication callback to it at runtime.

    Declaration
    public static void Duplicate(in T value, ref T duplicatedValue)
    Parameters
    Type Name Description
    T value
    T duplicatedValue
    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)