docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Constructor FastBufferReader

    FastBufferReader(NativeArray<byte>, Allocator, int, int, Allocator)

    Create a FastBufferReader from a NativeArray.

    A new buffer will be created using the given and the value will be copied in. FastBufferReader will then own the data.

    The exception to this is when the passed in is Allocator.None. In this scenario, ownership of the data remains with the caller and the reader will point at it directly. When created with Allocator.None, FastBufferReader will allocate some internal data using Allocator.Temp so it should be treated as if it's a ref struct and not allowed to outlive the context in which it was created (it should neither be returned from that function nor stored anywhere in heap memory). This is true, unless the param is explicitly set to i.e.: Allocator.Persistent in which case it would allow the internal data to Persist for longer, but the caller should manually call Dispose() when it is no longer needed.

    Declaration
    public FastBufferReader(NativeArray<byte> buffer, Allocator copyAllocator, int length = -1, int offset = 0, Allocator internalAllocator = Allocator.Temp)
    Parameters
    Type Name Description
    NativeArray<byte> buffer
    Allocator copyAllocator

    The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance

    int length
    int offset
    Allocator internalAllocator

    The allocator type used for internal data when this reader points directly at a buffer owned by someone else

    FastBufferReader(ArraySegment<byte>, Allocator, int, int)

    Create a FastBufferReader from an ArraySegment.

    A new buffer will be created using the given allocator and the value will be copied in. FastBufferReader will then own the data.

    Allocator.None is not supported for byte[]. If you need this functionality, use a fixed() block and ensure the FastBufferReader isn't used outside that block.

    Declaration
    public FastBufferReader(ArraySegment<byte> buffer, Allocator copyAllocator, int length = -1, int offset = 0)
    Parameters
    Type Name Description
    ArraySegment<byte> buffer

    The buffer to copy from

    Allocator copyAllocator

    The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance

    int length

    The number of bytes to copy (all if this is -1)

    int offset

    The offset of the buffer to start copying from

    FastBufferReader(byte[], Allocator, int, int)

    Create a FastBufferReader from an existing byte array.

    A new buffer will be created using the given allocator and the value will be copied in. FastBufferReader will then own the data.

    Allocator.None is not supported for byte[]. If you need this functionality, use a fixed() block and ensure the FastBufferReader isn't used outside that block.

    Declaration
    public FastBufferReader(byte[] buffer, Allocator copyAllocator, int length = -1, int offset = 0)
    Parameters
    Type Name Description
    byte[] buffer

    The buffer to copy from

    Allocator copyAllocator

    The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance

    int length

    The number of bytes to copy (all if this is -1)

    int offset

    The offset of the buffer to start copying from

    FastBufferReader(byte*, Allocator, int, int, Allocator)

    Create a FastBufferReader from an existing byte buffer.

    A new buffer will be created using the given and the value will be copied in. FastBufferReader will then own the data.

    The exception to this is when the passed in is Allocator.None. In this scenario, ownership of the data remains with the caller and the reader will point at it directly. When created with Allocator.None, FastBufferReader will allocate some internal data using Allocator.Temp, so it should be treated as if it's a ref struct and not allowed to outlive the context in which it was created (it should neither be returned from that function nor stored anywhere in heap memory). This is true, unless the param is explicitly set to i.e.: Allocator.Persistent in which case it would allow the internal data to Persist for longer, but the caller should manually call Dispose() when it is no longer needed.

    Declaration
    public FastBufferReader(byte* buffer, Allocator copyAllocator, int length, int offset = 0, Allocator internalAllocator = Allocator.Temp)
    Parameters
    Type Name Description
    byte* buffer

    The buffer to copy from

    Allocator copyAllocator

    The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance

    int length

    The number of bytes to copy

    int offset

    The offset of the buffer to start copying from

    Allocator internalAllocator

    The allocator type used for internal data when this reader points directly at a buffer owned by someone else

    FastBufferReader(FastBufferWriter, Allocator, int, int, Allocator)

    Create a FastBufferReader from a FastBufferWriter.

    A new buffer will be created using the given and the value will be copied in. FastBufferReader will then own the data.

    The exception to this is when the passed in is Allocator.None. In this scenario, ownership of the data remains with the caller and the reader will point at it directly. When created with Allocator.None, FastBufferReader will allocate some internal data using Allocator.Temp, so it should be treated as if it's a ref struct and not allowed to outlive the context in which it was created (it should neither be returned from that function nor stored anywhere in heap memory). This is true, unless the param is explicitly set to i.e.: Allocator.Persistent in which case it would allow the internal data to Persist for longer, but the caller should manually call Dispose() when it is no longer needed.

    Declaration
    public FastBufferReader(FastBufferWriter writer, Allocator copyAllocator, int length = -1, int offset = 0, Allocator internalAllocator = Allocator.Temp)
    Parameters
    Type Name Description
    FastBufferWriter writer

    The writer to copy from

    Allocator copyAllocator

    The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance

    int length

    The number of bytes to copy (all if this is -1)

    int offset

    The offset of the buffer to start copying from

    Allocator internalAllocator

    The allocator type used for internal data when this reader points directly at a buffer owned by someone else

    FastBufferReader(FastBufferReader, Allocator, int, int, Allocator)

    Create a FastBufferReader from another existing FastBufferReader. This is typically used when you want to change the copyAllocator that a reader is allocated to - for example, upgrading a Temp reader to a Persistent one to be processed later.

    A new buffer will be created using the given and the value will be copied in. FastBufferReader will then own the data.

    The exception to this is when the passed in is Allocator.None. In this scenario, ownership of the data remains with the caller and the reader will point at it directly. When created with Allocator.None, FastBufferReader will allocate some internal data using Allocator.Temp, so it should be treated as if it's a ref struct and not allowed to outlive the context in which it was created (it should neither be returned from that function nor stored anywhere in heap memory).

    Declaration
    public FastBufferReader(FastBufferReader reader, Allocator copyAllocator, int length = -1, int offset = 0, Allocator internalAllocator = Allocator.Temp)
    Parameters
    Type Name Description
    FastBufferReader reader

    The reader to copy from

    Allocator copyAllocator

    The allocator type used for internal data when copying an existing buffer if other than Allocator.None is specified, that memory will be owned by this FastBufferReader instance

    int length

    The number of bytes to copy (all if this is -1)

    int offset

    The offset of the buffer to start copying from

    Allocator internalAllocator

    The allocator type used for internal data when this reader points directly at a buffer owned by someone else

    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)