Class CustomGhostSerializerHelpers
Contains helper methods to write custom chunk serializers. See GhostPrefabCustomSerializer for more information about what a custom chunk serializer function pointer should be used for.
Inherited Members
Namespace: Unity.NetCode.LowLevel.Unsafe
Assembly: Unity.NetCode.dll
Syntax
public static class CustomGhostSerializerHelpers
Methods
CopyBufferToSnapshot<T>(T, ArchetypeChunk, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int, ref int)
Copy all buffers in the chunk for a given Unity.Entities.DynamicComponentTypeHandle to the snapshot buffer, starting from index startIndex to endIndex.
Declaration
public static void CopyBufferToSnapshot<T>(this T serializer, ArchetypeChunk chunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset, ref int dynamicSnapshotDataOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the serializer to use |
ArchetypeChunk | chunk | the chunk to copy |
GhostPrefabCustomSerializer.Context | context | the serialization context |
DynamicComponentTypeHandle* | typeHandles | the component type handles |
GhostCollectionComponentIndex | index | the GhostCollectionComponentIndex collection |
IntPtr | snapshotData | the snapshot buffer |
int | snapshotOffset | the start offset from the beginning of the snapshot buffer |
int | dynamicSnapshotDataOffset | the offset in the dynamic snapshot data buffer where the buffer data is stored |
Type Parameters
Name | Description |
---|---|
T | the buffer type |
CopyChildBufferToSnapshot<T>(T, ArchetypeChunk, int, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int, ref int)
Copy a single buffer on a child entity for a given Unity.Entities.DynamicComponentTypeHandle to the snapshot buffer.
Declaration
public static void CopyChildBufferToSnapshot<T>(this T serializer, ArchetypeChunk chunk, int indexInChunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset, ref int dynamicSnapshotOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the serializer to use |
ArchetypeChunk | chunk | the chunk to copy |
int | indexInChunk | the index in the chunk |
GhostPrefabCustomSerializer.Context | context | the serialization context |
DynamicComponentTypeHandle* | typeHandles | the component type handles |
GhostCollectionComponentIndex | index | the GhostCollectionComponentIndex collection |
IntPtr | snapshotData | the snapshot buffer |
int | snapshotOffset | the start offset from the beginning of the snapshot buffer |
int | dynamicSnapshotOffset | the offset in the dynamic snapshot data buffer where the buffer data is stored |
Type Parameters
Name | Description |
---|---|
T | the buffer type |
CopyChildComponentToSnapshot<T>(T, ArchetypeChunk, int, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int)
Copy a single component data for a child component to the snapshot buffer.
Declaration
public static void CopyChildComponentToSnapshot<T>(this T serializer, ArchetypeChunk chunk, int indexInChunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the serializer to use |
ArchetypeChunk | chunk | the chunk to copy |
int | indexInChunk | the index in the chunk |
GhostPrefabCustomSerializer.Context | context | the serialization context |
DynamicComponentTypeHandle* | typeHandles | the component type handles |
GhostCollectionComponentIndex | index | the GhostCollectionComponentIndex collection |
IntPtr | snapshotData | the snapshot buffer |
int | snapshotOffset | the start offset from the beginning of the snapshot buffer |
Type Parameters
Name | Description |
---|---|
T | the component type |
CopyComponentToSnapshot<T>(T, ArchetypeChunk, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int)
Copy the component data to the snapshot buffer for the whole chunk starting from index startIndex to endIndex.
Declaration
public static void CopyComponentToSnapshot<T>(this T serializer, ArchetypeChunk chunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the current serializer to use |
ArchetypeChunk | chunk | the chunk |
GhostPrefabCustomSerializer.Context | context | the serialization context |
DynamicComponentTypeHandle* | typeHandles | the component typehandles |
GhostCollectionComponentIndex | index | the GhostCollectionComponentIndex buffer |
IntPtr | snapshotData | the snapshot buffer data store |
int | snapshotOffset | the offset in bytes where the component data should be stored |
Type Parameters
Name | Description |
---|---|
T | the unmanaged component type |
CopyEnableBits(ArchetypeChunk, int, int, int, ref DynamicComponentTypeHandle, byte*, ref int)
Copy all the enable bits state for the given Unity.Entities.DynamicComponentTypeHandle to the snapshot buffer.
Declaration
public static void CopyEnableBits(ArchetypeChunk chunk, int startIndex, int endIndex, int snapshotStride, ref DynamicComponentTypeHandle componentTypeHandle, byte* enableMasks, ref int maskOffset)
Parameters
Type | Name | Description |
---|---|---|
ArchetypeChunk | chunk | the chunk |
int | startIndex | the start entity index |
int | endIndex | the end entity index (not inclusive) |
int | snapshotStride | the stride in bytes (the size) of the snapshot data for the given archretype |
DynamicComponentTypeHandle | componentTypeHandle | the component type handle to extrac |
byte* | enableMasks | the snapshot enable bit mask array |
int | maskOffset | the offset in bits in the array |