Struct GhostComponentSerializer
Assembly: Unity.NetCode.dll
Syntax
public struct GhostComponentSerializer
Fields
DynamicBufferComponentMaskBits
The number of change mask bits used the shadow buffer data. The change mask for the buffer is like this:
Declaration
public const int DynamicBufferComponentMaskBits = 2
Field Value
DynamicBufferComponentSnapshotSize
Dynamic Buffer have a special entry in the snapshot data that is used to track the len and offset of the
the buffer data inside the SnapshotDynamicDataBuffer buffer. This shadow component entry has the
following format:
Declaration
public const int DynamicBufferComponentSnapshotSize = 8
Field Value
Methods
ChangeMaskArraySizeInBytes(int)
Compute the number of bytes necessary to encode the required number of bits
Declaration
public static int ChangeMaskArraySizeInBytes(int numBits)
Parameters
| Type |
Name |
Description |
| int |
numBits |
|
Returns
| Type |
Description |
| int |
The min number of bytes to store this number of bits, rounded to the nearest 4 bytes (for data-alignment).
|
ChangeMaskArraySizeInUInts(int)
Compute the number of uint necessary to encode the required number of bits
Declaration
public static int ChangeMaskArraySizeInUInts(int numBits)
Parameters
| Type |
Name |
Description |
| int |
numBits |
|
Returns
| Type |
Description |
| int |
The uint mask to encode this number of bits.
|
ClearSnapshotDataAndMask(IntPtr, int, int, IntPtr, int, int)
Reset the changemask and the snapshot data to the default value (all 0)
Declaration
public static void ClearSnapshotDataAndMask(IntPtr snapshot, int snapshotOffset, int snapshotSize, IntPtr changeMask, int maskOffset, int changeMaskBits)
Parameters
| Type |
Name |
Description |
| IntPtr |
snapshot |
|
| int |
snapshotOffset |
|
| int |
snapshotSize |
|
| IntPtr |
changeMask |
|
| int |
maskOffset |
|
| int |
changeMaskBits |
|
ConvertToUnsafeList(IntPtr, int)
Helper method to construct an Unity.Collections.LowLevel.Unsafe.UnsafeList<T> from a given IntPtr and length.
Declaration
public static UnsafeList<float> ConvertToUnsafeList(IntPtr floatData, int len)
Parameters
| Type |
Name |
Description |
| IntPtr |
floatData |
|
| int |
len |
|
Returns
| Type |
Description |
| UnsafeList<float> |
|
CopyFromChangeMask(IntPtr, int, int)
Extract from the source buffer an unsigned integer, representing a portion of a bitmask
starting from the given offset and number of bits (up to 32 bits max).
Declaration
public static uint CopyFromChangeMask(IntPtr bitData, int offset, int numBits)
Parameters
Returns
CopyToChangeMask(IntPtr, uint, int, int)
For internal use only, copy the src bitmask to a destination buffer,
to the given offset and for the required number of bits.
Declaration
public static void CopyToChangeMask(IntPtr bitData, uint src, int offset, int numBits)
Parameters
GetDeltaCompressedSizeInBits(uint, uint, in StreamCompressionModel)
The compressed size in bits necessary to encode a given unsigned int value in delta in respect
to the given baseline.
Declaration
public static int GetDeltaCompressedSizeInBits(uint value, uint baseline, in StreamCompressionModel model)
Parameters
| Type |
Name |
Description |
| uint |
value |
the value to encode
|
| uint |
baseline |
the baseline used to calculate the delta
|
| StreamCompressionModel |
model |
the compression model to use
|
Returns
| Type |
Description |
| int |
the number of bits necessary to encode the value
|
IntPtrCast<T>(ref T)
Return a pointer to the memory address for the given value instance.
Declaration
public static IntPtr IntPtrCast<T>(ref T value) where T : struct
Parameters
| Type |
Name |
Description |
| T |
value |
|
Returns
Type Parameters
ResetChangeMask(IntPtr, int, int)
For internal use only, reset the bitData bitmask bits from the given offset
and for the required number of bits.
Declaration
public static void ResetChangeMask(IntPtr bitData, int offset, int numBits)
Parameters
SizeInSnapshot(in State)
Helper that returns the size in bytes (aligned to 16 bytes boundary) used to store the component data inside SnapshotData.
Declaration
public static int SizeInSnapshot(in GhostComponentSerializer.State serializer)
Parameters
Returns
SnapshotSizeAligned(int)
Align the give size to 16 byte boundary.
Declaration
public static int SnapshotSizeAligned(int size)
Parameters
| Type |
Name |
Description |
| int |
size |
|
Returns
SnapshotSizeAligned(uint)
Align the give size to 16 byte boundary
Declaration
public static uint SnapshotSizeAligned(uint size)
Parameters
| Type |
Name |
Description |
| uint |
size |
|
Returns
TypeCastReadonly<T>(IntPtr, int)
Helper method to get a reference to a struct data from its address in memory.
Declaration
public static ref readonly T TypeCastReadonly<T>(IntPtr value, int offset = 0) where T : struct
Parameters
| Type |
Name |
Description |
| IntPtr |
value |
|
| int |
offset |
|
Returns
Type Parameters
TypeCast<T>(IntPtr, int)
Helper method to get a reference to a struct data from its address in memory.
Declaration
public static ref T TypeCast<T>(IntPtr value, int offset = 0) where T : struct
Parameters
| Type |
Name |
Description |
| IntPtr |
value |
|
| int |
offset |
|
Returns
Type Parameters