Class BinarySerialization | Serialization | 1.2.0-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class BinarySerialization

    High level API for serializing or deserializing json data from string, file or stream.

    Inheritance
    Object
    BinarySerialization
    Namespace: Unity.Serialization.Binary
    Syntax
    public static class BinarySerialization

    Methods

    AddGlobalAdapter(IBinaryAdapter)

    Adds the specified IBinaryAdapter to the set of global adapters. This is be included by default in all BinarySerialization calls.

    Declaration
    public static void AddGlobalAdapter(IBinaryAdapter adapter)
    Parameters
    Type Name Description
    IBinaryAdapter adapter

    The adapter to add.

    Exceptions
    Type Condition
    ArgumentException

    The given adapter is already registered.

    FromBinary<T>(UnsafeAppendBuffer.Reader*, BinarySerializationParameters)

    Deserializes from the specified stream and returns a new instance of T.

    Declaration
    public static T FromBinary<T>(UnsafeAppendBuffer.Reader*stream, BinarySerializationParameters parameters = default(BinarySerializationParameters))
    Parameters
    Type Name Description
    UnsafeAppendBuffer.Reader* stream

    The stream to read from.

    BinarySerializationParameters parameters

    The parameters to use when reading.

    Returns
    Type Description
    T

    A new instance of T constructed from the serialized data.

    Type Parameters
    Name Description
    T

    The type to deserialize.

    ToBinary<T>(UnsafeAppendBuffer*, T, BinarySerializationParameters)

    Serializes the given object to the given stream as binary.

    Declaration
    public static void ToBinary<T>(UnsafeAppendBuffer*stream, T value, BinarySerializationParameters parameters = default(BinarySerializationParameters))
    Parameters
    Type Name Description
    UnsafeAppendBuffer* stream

    The stream to write the object to.

    T value

    The object to serialize.

    BinarySerializationParameters parameters

    Parameters to use when writing.

    Type Parameters
    Name Description
    T

    The type to serialize.

    In This Article
    • Methods
      • AddGlobalAdapter(IBinaryAdapter)
      • FromBinary<T>(UnsafeAppendBuffer.Reader*, BinarySerializationParameters)
      • ToBinary<T>(UnsafeAppendBuffer*, T, BinarySerializationParameters)
    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