Struct FastBufferWriter
Optimized class used for writing values into a byte stream FastBufferReader BytePacker ByteUnpacker
Implements
Inherited Members
Namespace: Unity.Netcode
Assembly: solution.dll
Syntax
public struct FastBufferWriter : IDisposable
Constructors
FastBufferWriter(int, Allocator, int)
Create a FastBufferWriter.
Declaration
public FastBufferWriter(int size, Allocator allocator, int maxSize = -1)
Parameters
Type | Name | Description |
---|---|---|
int | size | Size of the buffer to create |
Allocator | allocator | Allocator to use in creating it |
int | maxSize | Maximum size the buffer can grow to. If less than size, buffer cannot grow. |
Properties
Capacity
The current total buffer size
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
int |
IsInitialized
Gets a value indicating whether the writer has been initialized and a handle allocated.
Declaration
public bool IsInitialized { get; }
Property Value
Type | Description |
---|---|
bool |
Length
The total amount of bytes that have been written to the stream
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int |
MaxCapacity
The maximum possible total buffer size
Declaration
public int MaxCapacity { get; }
Property Value
Type | Description |
---|---|
int |
Position
The current write position
Declaration
public int Position { get; }
Property Value
Type | Description |
---|---|
int |
Methods
CopyFrom(FastBufferWriter)
Copy the contents of another writer into this writer. The contents will be copied from the beginning of the other writer to its current position. They will be copied to this writer starting at this writer's current position.
Declaration
public void CopyFrom(FastBufferWriter other)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | other | Writer to copy to |
CopyTo(FastBufferWriter)
Copy the contents of this writer into another writer. The contents will be copied from the beginning of this writer to its current position. They will be copied to the other writer starting at the other writer's current position.
Declaration
public void CopyTo(FastBufferWriter other)
Parameters
Type | Name | Description |
---|---|---|
FastBufferWriter | other | Writer to copy to |
Dispose()
IDisposable implementation that frees the allocated buffer
Declaration
public void Dispose()
EnterBitwiseContext()
Retrieve a BitWriter to be able to perform bitwise operations on the buffer. No bytewise operations can be performed on the buffer until bitWriter.Dispose() has been called. At the end of the operation, FastBufferWriter will remain byte-aligned.
Declaration
public BitWriter EnterBitwiseContext()
Returns
Type | Description |
---|---|
BitWriter | A BitWriter |
GetUnsafePtr()
Gets a direct pointer to the underlying buffer
Declaration
public byte* GetUnsafePtr()
Returns
Type | Description |
---|---|
byte* |
GetUnsafePtrAtCurrentPosition()
Gets a direct pointer to the underlying buffer at the current read position
Declaration
public byte* GetUnsafePtrAtCurrentPosition()
Returns
Type | Description |
---|---|
byte* |
GetWriteSize(string, bool)
Get the required size to write a string
Declaration
public static int GetWriteSize(string s, bool oneByteChars = false)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string to write |
bool | oneByteChars | Whether or not to use one byte per character. This will only allow ASCII |
Returns
Type | Description |
---|---|
int |
GetWriteSize<T>()
Get the size required to write an unmanaged value of type T
Declaration
public static int GetWriteSize<T>() where T : unmanaged
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T |
GetWriteSize<T>(NativeArray<T>, int, int)
Get the required size to write a NativeArray
Declaration
public static int GetWriteSize<T>(NativeArray<T> array, int count = -1, int offset = 0) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to write |
int | count | The amount of elements to write |
int | offset | Where in the array to start |
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T |
GetWriteSize<T>(in NativeArray<T>)
Get the write size for an array of FixedStrings
Declaration
public static int GetWriteSize<T>(in NativeArray<T> value) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | value |
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T |
GetWriteSize<T>(in T)
Get the write size for a FixedString
Declaration
public static int GetWriteSize<T>(in T value) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T | value |
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T |
GetWriteSize<T>(in T, ForStructs)
Get the write size for any general unmanaged value The ForStructs value here makes this the lowest-priority overload so other versions will be prioritized over this if they match
Declaration
public static int GetWriteSize<T>(in T value, FastBufferWriter.ForStructs unused = default) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForStructs | unused |
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T |
GetWriteSize<T>(T[], int, int)
Get the required size to write an unmanaged array
Declaration
public static int GetWriteSize<T>(T[] array, int count = -1, int offset = 0) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to write |
int | count | The amount of elements to write |
int | offset | Where in the array to start |
Returns
Type | Description |
---|---|
int |
Type Parameters
Name | Description |
---|---|
T |
Seek(int)
Move the write position in the stream. Note that moving forward past the current length will extend the buffer's Length value even if you don't write.
Declaration
public void Seek(int where)
Parameters
Type | Name | Description |
---|---|---|
int | where | Absolute value to move the position to, truncated to Capacity |
ToArray()
Returns an array representation of the underlying byte buffer. !!Allocates a new array!!
Declaration
public byte[] ToArray()
Returns
Type | Description |
---|---|
byte[] |
Truncate(int)
Truncate the stream by setting Length to the specified value. If Position is greater than the specified value, it will be moved as well.
Declaration
public void Truncate(int where = -1)
Parameters
Type | Name | Description |
---|---|---|
int | where | The value to truncate to. If -1, the current position will be used. |
TryBeginWrite(int)
Allows faster serialization by batching bounds checking. When you know you will be writing multiple fields back-to-back and you know the total size, you can call TryBeginWrite() once on the total size, and then follow it with calls to WriteValue() instead of WriteValueSafe() for faster serialization.
Unsafe write operations will throw OverflowException in editor and development builds if you go past the point you've marked using TryBeginWrite(). In release builds, OverflowException will not be thrown for performance reasons, since the point of using TryBeginWrite is to avoid bounds checking in the following operations in release builds.
Declaration
public bool TryBeginWrite(int bytes)
Parameters
Type | Name | Description |
---|---|---|
int | bytes | Amount of bytes to write |
Returns
Type | Description |
---|---|
bool | True if the write is allowed, false otherwise |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If called while in a bitwise context |
TryBeginWriteInternal(int)
Internal version of TryBeginWrite. Differs from TryBeginWrite only in that it won't ever move the AllowedWriteMark backward.
Declaration
public bool TryBeginWriteInternal(int bytes)
Parameters
Type | Name | Description |
---|---|---|
int | bytes |
Returns
Type | Description |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
TryBeginWriteValue<T>(in T)
Allows faster serialization by batching bounds checking. When you know you will be writing multiple fields back-to-back and you know the total size, you can call TryBeginWrite() once on the total size, and then follow it with calls to WriteValue() instead of WriteValueSafe() for faster serialization.
Unsafe write operations will throw OverflowException in editor and development builds if you go past the point you've marked using TryBeginWrite(). In release builds, OverflowException will not be thrown for performance reasons, since the point of using TryBeginWrite is to avoid bounds checking in the following operations in release builds. Instead, attempting to write past the marked position in release builds will write to random memory and cause undefined behavior, likely including instability and crashes.
Declaration
public bool TryBeginWriteValue<T>(in T value) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T | value | The value of the type |
Returns
Type | Description |
---|---|
bool | True if the write is allowed, false otherwise |
Type Parameters
Name | Description |
---|---|
T | The value type to write |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If called while in a bitwise context |
WriteByte(byte)
Write a byte to the stream.
Declaration
public void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | Value to write |
WriteByteSafe(byte)
Write a byte to the stream.
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteByteSafe(byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | Value to write |
WriteBytes(byte*, int, int)
Write multiple bytes to the stream
Declaration
public void WriteBytes(byte* value, int size, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
byte* | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytes(byte[], int, int)
Write multiple bytes to the stream
Declaration
public void WriteBytes(byte[] value, int size = -1, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
byte[] | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytes(NativeArray<byte>, int, int)
Write multiple bytes to the stream
Declaration
public void WriteBytes(NativeArray<byte> value, int size = -1, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<byte> | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytes(NativeList<byte>, int, int)
Write multiple bytes to the stream
Declaration
public void WriteBytes(NativeList<byte> value, int size = -1, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
NativeList<byte> | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytesSafe(byte*, int, int)
Write multiple bytes to the stream
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteBytesSafe(byte* value, int size, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
byte* | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytesSafe(byte[], int, int)
Write multiple bytes to the stream
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteBytesSafe(byte[] value, int size = -1, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
byte[] | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytesSafe(NativeArray<byte>, int, int)
Write multiple bytes to the stream
Declaration
public void WriteBytesSafe(NativeArray<byte> value, int size = -1, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<byte> | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteBytesSafe(NativeList<byte>, int, int)
Write multiple bytes to the stream
Declaration
public void WriteBytesSafe(NativeList<byte> value, int size = -1, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
NativeList<byte> | value | Value to write |
int | size | Number of bytes to write |
int | offset | Offset into the buffer to begin writing |
WriteNetworkSerializable<T>(NativeArray<T>, int, int)
Write a NativeArray of INetworkSerializables
Declaration
public void WriteNetworkSerializable<T>(NativeArray<T> array, int count = -1, int offset = 0) where T : unmanaged, INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The value to write |
int | count | |
int | offset |
Type Parameters
Name | Description |
---|---|
T |
WriteNetworkSerializable<T>(in T)
Write an INetworkSerializable
Declaration
public void WriteNetworkSerializable<T>(in T value) where T : INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
Type Parameters
Name | Description |
---|---|
T |
WriteNetworkSerializable<T>(T[], int, int)
Write an array of INetworkSerializables
Declaration
public void WriteNetworkSerializable<T>(T[] array, int count = -1, int offset = 0) where T : INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The value to write |
int | count | |
int | offset |
Type Parameters
Name | Description |
---|---|
T |
WritePartialValue<T>(T, int, int)
Write a partial value. The specified number of bytes is written from the value and the rest is ignored.
Declaration
public void WritePartialValue<T>(T value, int bytesToWrite, int offsetBytes = 0) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to write |
int | bytesToWrite | Number of bytes |
int | offsetBytes | Offset into the value to begin reading the bytes |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | |
OverflowException |
WriteValue(string, bool)
Writes a string
Declaration
public void WriteValue(string s, bool oneByteChars = false)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string to write |
bool | oneByteChars | Whether or not to use one byte per character. This will only allow ASCII |
WriteValue(in Color32)
Write a Color32
Declaration
public void WriteValue(in Color32 value)
Parameters
Type | Name | Description |
---|---|---|
Color32 | value | the value to write |
WriteValue(Color32[])
Write a Color32 array
Declaration
public void WriteValue(Color32[] value)
Parameters
Type | Name | Description |
---|---|---|
Color32[] | value | the values to write |
WriteValue(in Color)
Write a Color
Declaration
public void WriteValue(in Color value)
Parameters
Type | Name | Description |
---|---|---|
Color | value | the value to write |
WriteValue(Color[])
Write a Color array
Declaration
public void WriteValue(Color[] value)
Parameters
Type | Name | Description |
---|---|---|
Color[] | value | the values to write |
WriteValue(in Quaternion)
Write a Quaternion
Declaration
public void WriteValue(in Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | the value to write |
WriteValue(Quaternion[])
Write a Quaternion array
Declaration
public void WriteValue(Quaternion[] value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion[] | value | the values to write |
WriteValue(in Ray2D)
Write a Ray2D
Declaration
public void WriteValue(in Ray2D value)
Parameters
Type | Name | Description |
---|---|---|
Ray2D | value | the value to write |
WriteValue(Ray2D[])
Write a Ray2D array
Declaration
public void WriteValue(Ray2D[] value)
Parameters
Type | Name | Description |
---|---|---|
Ray2D[] | value | the values to write |
WriteValue(in Ray)
Write a Ray
Declaration
public void WriteValue(in Ray value)
Parameters
Type | Name | Description |
---|---|---|
Ray | value | the value to write |
WriteValue(Ray[])
Write a Ray array
Declaration
public void WriteValue(Ray[] value)
Parameters
Type | Name | Description |
---|---|---|
Ray[] | value | the values to write |
WriteValue(in Vector2)
Write a Vector2
Declaration
public void WriteValue(in Vector2 value)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | the value to write |
WriteValue(in Vector2Int)
Write a Vector2Int
Declaration
public void WriteValue(in Vector2Int value)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | value | the value to write |
WriteValue(Vector2Int[])
Write a Vector2Int array
Declaration
public void WriteValue(Vector2Int[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int[] | value | the values to write |
WriteValue(Vector2[])
Write a Vector2 array
Declaration
public void WriteValue(Vector2[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector2[] | value | the values to write |
WriteValue(in Vector3)
Write a Vector3
Declaration
public void WriteValue(in Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | the value to write |
WriteValue(in Vector3Int)
Write a Vector3Int
Declaration
public void WriteValue(in Vector3Int value)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | value | the value to write |
WriteValue(Vector3Int[])
Write a Vector3Int array
Declaration
public void WriteValue(Vector3Int[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int[] | value | the value to write |
WriteValue(Vector3[])
Write a Vector3 array
Declaration
public void WriteValue(Vector3[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | value | the values to write |
WriteValue(in Vector4)
Write a Vector4
Declaration
public void WriteValue(in Vector4 value)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | value | the value to write |
WriteValue(Vector4[])
Write a Vector4
Declaration
public void WriteValue(Vector4[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector4[] | value | the values to write |
WriteValueSafe(string, bool)
Writes a string
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(string s, bool oneByteChars = false)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string to write |
bool | oneByteChars | Whether or not to use one byte per character. This will only allow ASCII |
WriteValueSafe(in Color32)
Write a Color32
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Color32 value)
Parameters
Type | Name | Description |
---|---|---|
Color32 | value | the value to write |
WriteValueSafe(Color32[])
Write a Color32 array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Color32[] value)
Parameters
Type | Name | Description |
---|---|---|
Color32[] | value | the values to write |
WriteValueSafe(in Color)
Write a Color
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Color value)
Parameters
Type | Name | Description |
---|---|---|
Color | value | the value to write |
WriteValueSafe(Color[])
Write a Collor array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Color[] value)
Parameters
Type | Name | Description |
---|---|---|
Color[] | value | the values to write |
WriteValueSafe(in Quaternion)
Write a Quaternion
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | the value to write |
WriteValueSafe(Quaternion[])
Write a Quaternion array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Quaternion[] value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion[] | value | the values to write |
WriteValueSafe(in Ray2D)
Write a Ray2D
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Ray2D value)
Parameters
Type | Name | Description |
---|---|---|
Ray2D | value | the value to write |
WriteValueSafe(Ray2D[])
Write a Ray2D array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Ray2D[] value)
Parameters
Type | Name | Description |
---|---|---|
Ray2D[] | value | the values to write |
WriteValueSafe(in Ray)
Write a Ray
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Ray value)
Parameters
Type | Name | Description |
---|---|---|
Ray | value | the value to write |
WriteValueSafe(Ray[])
Write a Ray array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Ray[] value)
Parameters
Type | Name | Description |
---|---|---|
Ray[] | value | the values to write |
WriteValueSafe(in Vector2)
Write a Vector2
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Vector2 value)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | the value to write |
WriteValueSafe(in Vector2Int)
Write a Vector2Int
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Vector2Int value)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | value | the value to write |
WriteValueSafe(Vector2Int[])
Write a Vector2Int array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Vector2Int[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int[] | value | the values to write |
WriteValueSafe(Vector2[])
Write a Vector2 array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Vector2[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector2[] | value | the values to write |
WriteValueSafe(in Vector3)
Write a Vector3
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | the value to write |
WriteValueSafe(in Vector3Int)
Write a Vector3Int
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Vector3Int value)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | value | the value to write |
WriteValueSafe(Vector3Int[])
Write a Vector3Int array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Vector3Int[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int[] | value | the values to write |
WriteValueSafe(Vector3[])
Write a Vector3 array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Vector3[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | value | the values to write |
WriteValueSafe(in Vector4)
Write a Vector4
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(in Vector4 value)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | value | the value to write |
WriteValueSafe(Vector4[])
Write a Vector4 array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe(Vector4[] value)
Parameters
Type | Name | Description |
---|---|---|
Vector4[] | value | the values to write |
WriteValueSafe<T>(NativeArray<T>, ForGeneric)
Write a struct NativeArray
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(NativeArray<T> value, FastBufferWriter.ForGeneric unused = default) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | value | The values to write |
FastBufferWriter.ForGeneric | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(in NativeArray<T>)
Write a NativeArray of FixedString values. Writes only the part of each string that's actually used. "Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(in NativeArray<T> value) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | value | the value to write |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(in T, ForEnums)
Write an enum value
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(in T value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForEnums | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(in T, ForFixedStrings)
Write a FixedString value. Writes only the part of the string that's actually used.
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(in T value, FastBufferWriter.ForFixedStrings unused = default) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T | value | the value to write |
FastBufferWriter.ForFixedStrings | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(in T, ForNetworkSerializable)
Write a NetworkSerializable value
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(in T value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForNetworkSerializable | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(in T, ForPrimitives)
Write a primitive value (int, bool, etc) Accepts any value that implements the given interfaces, but is not guaranteed to work correctly on values that are not primitives.
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(in T value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForPrimitives | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(in T, ForStructs)
Write a struct
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(in T value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForStructs | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(T[], ForEnums)
Write an enum array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(T[] value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForEnums | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(T[], ForFixedStrings)
Write a NativeArray of FixedString values. Writes only the part of each string that's actually used. "Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(T[] value, FastBufferWriter.ForFixedStrings unused = default) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T[] | value | the value to write |
FastBufferWriter.ForFixedStrings | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(T[], ForNetworkSerializable)
Write a NetworkSerializable array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(T[] value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForNetworkSerializable | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(T[], ForPrimitives)
Write a primitive value (int, bool, etc) Accepts any value that implements the given interfaces, but is not guaranteed to work correctly on values that are not primitives.
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(T[] value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The value to write |
FastBufferWriter.ForPrimitives | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValueSafe<T>(T[], ForStructs)
Write a struct array
"Safe" version - automatically performs bounds checking. Less efficient than bounds checking for multiple writes at once by calling TryBeginWrite.
Declaration
public void WriteValueSafe<T>(T[] value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForStructs | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(NativeArray<T>, ForGeneric)
Write a struct NativeArray
Declaration
public void WriteValue<T>(NativeArray<T> value, FastBufferWriter.ForGeneric unused = default) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | value | The values to write |
FastBufferWriter.ForGeneric | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(in NativeArray<T>, ForFixedStrings)
Write a NativeArray of FixedString values. Writes only the part of each string that's actually used. When calling TryBeginWrite, ensure you calculate the write size correctly (preferably by calling FastBufferWriter.GetWriteSize())
Declaration
public void WriteValue<T>(in NativeArray<T> value, FastBufferWriter.ForFixedStrings unused = default) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | value | the value to write |
FastBufferWriter.ForFixedStrings | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(in T, ForEnums)
Write an enum value
Declaration
public void WriteValue<T>(in T value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForEnums | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(in T, ForFixedStrings)
Write a FixedString value. Writes only the part of the string that's actually used. When calling TryBeginWrite, ensure you calculate the write size correctly (preferably by calling FastBufferWriter.GetWriteSize())
Declaration
public void WriteValue<T>(in T value, FastBufferWriter.ForFixedStrings unused = default) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T | value | the value to write |
FastBufferWriter.ForFixedStrings | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(in T, ForNetworkSerializable)
Write a NetworkSerializable value
Declaration
public void WriteValue<T>(in T value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForNetworkSerializable | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(in T, ForPrimitives)
Write a primitive value (int, bool, etc) Accepts any value that implements the given interfaces, but is not guaranteed to work correctly on values that are not primitives.
Declaration
public void WriteValue<T>(in T value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForPrimitives | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(in T, ForStructs)
Write a struct
Declaration
public void WriteValue<T>(in T value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write |
FastBufferWriter.ForStructs | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(T[], ForEnums)
Write an enum array
Declaration
public void WriteValue<T>(T[] value, FastBufferWriter.ForEnums unused = default) where T : unmanaged, Enum
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForEnums | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(T[], ForFixedStrings)
Write an array of FixedString values. Writes only the part of each string that's actually used. When calling TryBeginWrite, ensure you calculate the write size correctly (preferably by calling FastBufferWriter.GetWriteSize())
Declaration
public void WriteValue<T>(T[] value, FastBufferWriter.ForFixedStrings unused = default) where T : unmanaged, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T[] | value | the value to write |
FastBufferWriter.ForFixedStrings | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(T[], ForNetworkSerializable)
Write a NetworkSerializable array
Declaration
public void WriteValue<T>(T[] value, FastBufferWriter.ForNetworkSerializable unused = default) where T : INetworkSerializable
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForNetworkSerializable | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(T[], ForPrimitives)
Write a primitive value array (int, bool, etc) Accepts any value that implements the given interfaces, but is not guaranteed to work correctly on values that are not primitives.
Declaration
public void WriteValue<T>(T[] value, FastBufferWriter.ForPrimitives unused = default) where T : unmanaged, IComparable, IConvertible, IComparable<T>, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForPrimitives | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |
WriteValue<T>(T[], ForStructs)
Write a struct array
Declaration
public void WriteValue<T>(T[] value, FastBufferWriter.ForStructs unused = default) where T : unmanaged, INetworkSerializeByMemcpy
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The values to write |
FastBufferWriter.ForStructs | unused | An unused parameter used for enabling overload resolution based on generic constraints |
Type Parameters
Name | Description |
---|---|
T | The type being serialized |