docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct UnsafeAppendBuffer.Reader

    A reader for UnsafeAppendBuffer.

    Namespace: Unity.Collections.LowLevel.Unsafe
    Assembly: Unity.Collections.dll
    Syntax
    public struct UnsafeAppendBuffer.Reader

    Constructors

    Reader(void*, int)

    Initializes and returns an instance of UnsafeAppendBuffer.Reader that reads from a buffer.

    Declaration
    public Reader(void* ptr, int length)
    Parameters
    Type Name Description
    void* ptr

    The buffer to read as an UnsafeAppendBuffer.

    int length

    The length in bytes of the

    Remarks

    The buffer will be read as if it is an UnsafeAppendBuffer whether it was originally allocated as one or not.

    Reader(ref UnsafeAppendBuffer)

    Initializes and returns an instance of UnsafeAppendBuffer.Reader.

    Declaration
    public Reader(ref UnsafeAppendBuffer buffer)
    Parameters
    Type Name Description
    UnsafeAppendBuffer buffer

    A reference to the append buffer to read.

    Fields

    Offset

    The location of the next read (expressed as a byte offset from the start).

    Declaration
    public int Offset
    Field Value
    Type Description
    int

    The location of the next read (expressed as a byte offset from the start).

    Ptr

    The internal buffer where the content is stored.

    Declaration
    public readonly byte* Ptr
    Field Value
    Type Description
    byte*

    The internal buffer where the content is stored.

    Size

    The length in bytes of the append buffer's content.

    Declaration
    public readonly int Size
    Field Value
    Type Description
    int

    The length in bytes of the append buffer's content.

    Properties

    EndOfBuffer

    Whether the offset has advanced past the last of the append buffer's content.

    Declaration
    public bool EndOfBuffer { get; }
    Property Value
    Type Description
    bool

    Whether the offset has advanced past the last of the append buffer's content.

    Methods

    ReadNext(int)

    Reads an element from the append buffer.

    Declaration
    public void* ReadNext(int structSize)
    Parameters
    Type Name Description
    int structSize

    The size of the element to read.

    Returns
    Type Description
    void*

    A pointer to where the read element resides in the append buffer.

    Remarks

    Advances the reader's offset by structSize.

    ReadNextArray<T>(out int)

    Reads an array from the append buffer.

    Declaration
    public void* ReadNextArray<T>(out int length) where T : unmanaged
    Parameters
    Type Name Description
    int length

    Output which is the number of elements in the read array.

    Returns
    Type Description
    void*

    A pointer to where the first element of the read array resides in the append buffer.

    Type Parameters
    Name Description
    T

    The type of elements in the array to read.

    Remarks

    An array stored in the append buffer starts with an int specifying the number of values in the array. The first element of an array immediately follows this int.

     Advances the reader's offset by the size of the array (plus an int).
    

    ReadNext<T>()

    Reads an element from the append buffer.

    Declaration
    public T ReadNext<T>() where T : unmanaged
    Returns
    Type Description
    T

    The element read.

    Type Parameters
    Name Description
    T

    The type of element to read.

    Remarks

    Advances the reader's offset by the size of T.

    ReadNext<T>(out NativeArray<T>, AllocatorHandle)

    Reads an element from the append buffer.

    Declaration
    public void ReadNext<T>(out NativeArray<T> value, AllocatorManager.AllocatorHandle allocator) where T : unmanaged
    Parameters
    Type Name Description
    NativeArray<T> value

    Outputs a new array with length of 1. The read element is copied to the single index of this array.

    AllocatorManager.AllocatorHandle allocator

    The allocator to use.

    Type Parameters
    Name Description
    T

    The type of element to read.

    Remarks

    Advances the reader's offset by the size of T.

    ReadNext<T>(out T)

    Reads an element from the append buffer.

    Declaration
    public void ReadNext<T>(out T value) where T : unmanaged
    Parameters
    Type Name Description
    T value

    Output for the element read.

    Type Parameters
    Name Description
    T

    The type of element to read.

    Remarks

    Advances the reader's offset by the size of T.

    Extension Methods

    Extensions.ReadNextNBC(ref UnsafeAppendBuffer.Reader, out string)
    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)