docs.unity3d.com
    目次を表示する/隠す

    Struct UnsafeStream.Reader

    Reads data from a buffer of an UnsafeStream.

    Namespace: Unity.Collections.LowLevel.Unsafe
    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 readonly 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 readonly 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 remaining elements 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()

    Does nothing.

    Declaration
    public void EndForEachIndex()
    Remarks

    Included only for consistency with NativeStream.

    Peek<T>()

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

    Declaration
    public ref 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 ref 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.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the reader has been advanced past the end of the buffer.

    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)