Skip to main content

Unity.Netcode.BitReader

Helper class for doing bitwise reads for a FastBufferReader. Ensures all bitwise reads end on proper byte alignment so FastBufferReader doesn't have to be concerned with misaligned reads.

Inherited Members#

ValueType.Equals(Object)

ValueType.GetHashCode()

ValueType.ToString()

Object.Equals(Object, Object)

Object.GetType()

Object.ReferenceEquals(Object, Object)

Namespace: System.Dynamic.ExpandoObject#
Assembly: MLAPI.dll#
Syntax#
public ref struct BitReader

BitAligned#

Whether or not the current BitPosition is evenly divisible by 8. I.e. whether or not the BitPosition is at a byte boundary.

Declaration#

public readonly bool BitAligned { get; }

Property Value#

TypeDescription
System.Boolean

#

Dispose()#

Pads the read bit count to byte alignment and commits the read back to the reader

Declaration#

public void Dispose()

ReadBit(out Boolean)#

Read a single bit from the buffer

Declaration#

public void ReadBit(out bool bit)

Parameters#

TypeNameDescription
System.BooleanbitOut value of the bit. True represents 1, False represents 0

ReadBits(out Byte, UInt32)#

Read bits from stream.

Declaration#

public void ReadBits(out byte value, uint bitCount)

Parameters#

TypeNameDescription
System.BytevalueValue to store bits into.
System.UInt32bitCountAmount of bits to read.

ReadBits(out UInt64, UInt32)#

Read a certain amount of bits from the stream.

Declaration#

public void ReadBits(out ulong value, uint bitCount)

Parameters#

TypeNameDescription
System.UInt64valueValue to store bits into.
System.UInt32bitCountAmount of bits to read

TryBeginReadBits(UInt32)#

Verifies the requested bit count can be read from the buffer. This exists as a separate method to allow multiple bit reads to be bounds checked with a single call. If it returns false, you may not read, and in editor and development builds, attempting to do so will throw an exception. In release builds, attempting to do so will read junk memory.

Declaration#

public bool TryBeginReadBits(uint bitCount)

Parameters#

TypeNameDescription
System.UInt32bitCountNumber of bits you want to read, in total

Returns#

TypeDescription
System.BooleanTrue if you can read, false if that would exceed buffer bounds