docs.unity.cn
    Show / Hide Table of Contents

    Struct NativeStream.Reader

    Reads data from a buffer of a NativeStream.

    Namespace: Unity.Collections
    Syntax
    public struct Reader
    Remarks

    An individual reader can only be used for one buffer of one stream. Do not create more than one reader for an individual buffer.

    Properties

    ForEachCount

    The number of buffers in the stream of this reader.

    Declaration
    public int ForEachCount { get; }
    Property Value
    Type Description
    Int32

    The number of buffers in the stream of this reader.

    RemainingItemCount

    The number of items not yet read from the buffer.

    Declaration
    public int RemainingItemCount { get; }
    Property Value
    Type Description
    Int32

    The number of items not yet read from the buffer.

    Methods

    BeginForEachIndex(Int32)

    Readies this reader to read a particular buffer of the stream.

    Declaration
    public int BeginForEachIndex(int foreachIndex)
    Parameters
    Type Name Description
    Int32 foreachIndex

    The index of the buffer to read.

    Returns
    Type Description
    Int32

    The number of elements left to read from the buffer.

    Remarks

    Must be called before using this reader. For an individual reader, call this method only once.

    When done using this reader, you must call EndForEachIndex().

    Count()

    Returns the total number of items in the buffers of the stream.

    Declaration
    public int Count()
    Returns
    Type Description
    Int32

    The total number of items in the buffers of the stream.

    EndForEachIndex()

    Checks if all data has been read from the buffer.

    Declaration
    public void EndForEachIndex()
    Remarks

    If you intentionally don't want to read all the data in the buffer, don't call this method. Otherwise, calling this method is recommended, even though it's not strictly necessary.

    Peek<T>()

    Reads the next value from the buffer. Does not advance the reader.

    Declaration
    public T Peek<T>()
        where T : struct
    Returns
    Type Description
    T

    A reference to the next value from the buffer.

    Type Parameters
    Name Description
    T

    The type of value to read.

    Read<T>()

    Reads the next value from the buffer.

    Declaration
    public T Read<T>()
        where T : struct
    Returns
    Type Description
    T

    A reference to the next value from the buffer.

    Type Parameters
    Name Description
    T

    The type of value to read.

    Remarks

    Each read advances the reader to the next item in the buffer.

    ReadUnsafePtr(Int32)

    Returns a pointer to the next position to read from the buffer. Advances the reader some number of bytes.

    Declaration
    public byte *ReadUnsafePtr(int size)
    Parameters
    Type Name Description
    Int32 size

    The number of bytes to advance the reader.

    Returns
    Type Description
    Byte*

    A pointer to the next position to read from the buffer.

    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Wednesday, September 29, 2021