docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkVariableSerializationTypedInitializers

    This class contains initialization functions for various different types used in NetworkVariables. Generally speaking, these methods are called by a module initializer created by codegen (NetworkBehaviourILPP) and do not need to be called manually.

    There are two types of initializers: Serializers and EqualityCheckers. Every type must have an EqualityChecker registered to it in order to be used in NetworkVariable; however, not all types need a Serializer. Types without a serializer registered will fall back to using the delegates in UserNetworkVariableSerialization<T>. If no such delegate has been registered, a type without a serializer will throw an exception on the first attempt to serialize or deserialize it. (Again, however, codegen handles this automatically and this registration doesn't typically need to be performed manually.)

    Inheritance
    object
    NetworkVariableSerializationTypedInitializers
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Netcode
    Assembly: Unity.Netcode.Runtime.dll
    Syntax
    public static class NetworkVariableSerializationTypedInitializers

    Methods

    InitializeEqualityChecker_Dictionary<TKey, TVal>()

    Registers an unmanaged type that will be checked for equality using T.Equals()

    Declaration
    public static void InitializeEqualityChecker_Dictionary<TKey, TVal>() where TKey : IEquatable<TKey>
    Type Parameters
    Name Description
    TKey

    The type of keys in the Dictionary, must implement IEquatable

    TVal

    The type of values in the Dictionary

    InitializeEqualityChecker_HashSet<T>()

    Registers an unmanaged type that will be checked for equality using T.Equals()

    Declaration
    public static void InitializeEqualityChecker_HashSet<T>() where T : IEquatable<T>
    Type Parameters
    Name Description
    T

    The type of elements in the HashSet

    InitializeEqualityChecker_List<T>()

    Registers an unmanaged type that will be checked for equality using T.Equals()

    Declaration
    public static void InitializeEqualityChecker_List<T>()
    Type Parameters
    Name Description
    T

    The type of elements in the List

    InitializeEqualityChecker_ManagedClassEquals<T>()

    Registers a managed type that will be checked for equality using the == operator

    Declaration
    public static void InitializeEqualityChecker_ManagedClassEquals<T>() where T : class
    Type Parameters
    Name Description
    T

    The class type to register for equality checking

    InitializeEqualityChecker_ManagedIEquatable<T>()

    Registers a managed type that will be checked for equality using T.Equals()

    Declaration
    public static void InitializeEqualityChecker_ManagedIEquatable<T>() where T : class, IEquatable<T>
    Type Parameters
    Name Description
    T

    The managed type that implements IEquatable

    InitializeEqualityChecker_UnmanagedIEquatableArray<T>()

    Registers an unmanaged type that will be checked for equality using T.Equals()

    Declaration
    public static void InitializeEqualityChecker_UnmanagedIEquatableArray<T>() where T : unmanaged, IEquatable<T>
    Type Parameters
    Name Description
    T

    The unmanaged element type that implements IEquatable

    InitializeEqualityChecker_UnmanagedIEquatable<T>()

    Registers an unmanaged type that will be checked for equality using T.Equals()

    Declaration
    public static void InitializeEqualityChecker_UnmanagedIEquatable<T>() where T : unmanaged, IEquatable<T>
    Type Parameters
    Name Description
    T

    The unmanaged type to register

    InitializeEqualityChecker_UnmanagedValueEqualsArray<T>()

    Registers an unmanaged type that will be checked for equality using memcmp and only considered equal if they are bitwise equivalent in memory

    Declaration
    public static void InitializeEqualityChecker_UnmanagedValueEqualsArray<T>() where T : unmanaged
    Type Parameters
    Name Description
    T

    The unmanaged element type to register for equality checking

    InitializeEqualityChecker_UnmanagedValueEquals<T>()

    Registers an unmanaged type that will be checked for equality using memcmp and only considered equal if they are bitwise equivalent in memory

    Declaration
    public static void InitializeEqualityChecker_UnmanagedValueEquals<T>() where T : unmanaged
    Type Parameters
    Name Description
    T

    The unmanaged type to register for equality checking

    InitializeSerializer_Dictionary<TKey, TVal>()

    Registeres a native hash set (this generic implementation works with all types)

    Declaration
    public static void InitializeSerializer_Dictionary<TKey, TVal>() where TKey : IEquatable<TKey>
    Type Parameters
    Name Description
    TKey

    The type of keys in the Dictionary, must implement IEquatable

    TVal

    The type of values stored in the Dictionary

    InitializeSerializer_FixedStringArray<T>()

    Registers a FixedString type that will be serialized through FastBufferReader/FastBufferWriter's FixedString serializers

    Declaration
    public static void InitializeSerializer_FixedStringArray<T>() where T : unmanaged, INativeList<byte>, IUTF8Bytes
    Type Parameters
    Name Description
    T

    The FixedString type that implements INativeList and IUTF8Bytes

    InitializeSerializer_FixedString<T>()

    Registers a FixedString type that will be serialized through FastBufferReader/FastBufferWriter's FixedString serializers

    Declaration
    public static void InitializeSerializer_FixedString<T>() where T : unmanaged, INativeList<byte>, IUTF8Bytes
    Type Parameters
    Name Description
    T

    The FixedString type that implements INativeList and IUTF8Bytes

    InitializeSerializer_HashSet<T>()

    Registeres a native hash set (this generic implementation works with all types)

    Declaration
    public static void InitializeSerializer_HashSet<T>() where T : IEquatable<T>
    Type Parameters
    Name Description
    T

    The type of elements contained in the HashSet, must implement IEquatable

    InitializeSerializer_List<T>()

    Registeres a native hash set (this generic implementation works with all types)

    Declaration
    public static void InitializeSerializer_List<T>()
    Type Parameters
    Name Description
    T

    The type of elements contained in the List

    InitializeSerializer_ManagedINetworkSerializable<T>()

    Registers a managed type that implements INetworkSerializable and will be serialized through a call to NetworkSerialize

    Declaration
    public static void InitializeSerializer_ManagedINetworkSerializable<T>() where T : class, INetworkSerializable, new()
    Type Parameters
    Name Description
    T

    The managed type that implements INetworkSerializable and has a parameterless constructor

    InitializeSerializer_UnmanagedByMemcpyArray<T>()

    Registeres an unmanaged type that will be serialized by a direct memcpy into a buffer

    Declaration
    public static void InitializeSerializer_UnmanagedByMemcpyArray<T>() where T : unmanaged
    Type Parameters
    Name Description
    T

    The unmanaged element type of the array to be registered for serialization

    InitializeSerializer_UnmanagedByMemcpy<T>()

    Registeres an unmanaged type that will be serialized by a direct memcpy into a buffer

    Declaration
    public static void InitializeSerializer_UnmanagedByMemcpy<T>() where T : unmanaged
    Type Parameters
    Name Description
    T

    The unmanaged type to be registered for serialization

    InitializeSerializer_UnmanagedINetworkSerializableArray<T>()

    Registers an unmanaged type that implements INetworkSerializable and will be serialized through a call to NetworkSerialize

    Declaration
    public static void InitializeSerializer_UnmanagedINetworkSerializableArray<T>() where T : unmanaged, INetworkSerializable
    Type Parameters
    Name Description
    T

    The unmanaged element type that implements INetworkSerializable

    InitializeSerializer_UnmanagedINetworkSerializable<T>()

    Registers an unmanaged type that implements INetworkSerializable and will be serialized through a call to NetworkSerialize

    Declaration
    public static void InitializeSerializer_UnmanagedINetworkSerializable<T>() where T : unmanaged, INetworkSerializable
    Type Parameters
    Name Description
    T

    The unmanaged type that implements INetworkSerializable

    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)