Inherited Members#
System.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
Syntax#
Constructors#
FastBufferWriter(Int32, Allocator, Int32)#
Create a FastBufferWriter.
Declaration#
Parameters#
Type | Name | Description |
---|
System.Int32 | size | Size of the buffer to create |
Allocator | allocator | Allocator to use in creating it |
System.Int32 | maxSize | Maximum size the buffer can grow to. If less than size, buffer cannot grow. |
Properties#
Capacity#
The current total buffer size
Declaration#
Property Value#
Type | Description |
---|
System.Int32 | |
IsInitialized#
Gets a value indicating whether the writer has been initialized and a
handle allocated.
Declaration#
Property Value#
Type | Description |
---|
System.Boolean | |
Length#
The total amount of bytes that have been written to the stream
Declaration#
Property Value#
Type | Description |
---|
System.Int32 | |
MaxCapacity#
The maximum possible total buffer size
Declaration#
Property Value#
Type | Description |
---|
System.Int32 | |
Position#
The current write position
Declaration#
Property Value#
Type | Description |
---|
System.Int32 | |
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#
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#
Parameters#
Type | Name | Description |
---|
FastBufferWriter | other | Writer to copy to |
Dispose()#
Frees the allocated buffer
Declaration#
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#
Returns#
Type | Description |
---|
BitWriter | A BitWriter |
GetUnsafePtr()#
Gets a direct pointer to the underlying buffer
Declaration#
Returns#
Type | Description |
---|
System.Byte* | |
GetUnsafePtrAtCurrentPosition()#
Gets a direct pointer to the underlying buffer at the current read
position
Declaration#
Returns#
Type | Description |
---|
System.Byte* | |
GetWriteSize(String, Boolean)#
Get the required size to write a string
Declaration#
Parameters#
Type | Name | Description |
---|
System.String | s | The string to write |
System.Boolean | oneByteChars | Whether or not to use one byte per character. This will only allow ASCII |
Returns#
Type | Description |
---|
System.Int32 | |
GetWriteSize\<T>()#
Get the size required to write an unmanaged value of type T
Declaration#
Returns#
Type | Description |
---|
System.Int32 | |
Type Parameters#
GetWriteSize\<T>(in T)#
Get the size required to write an unmanaged value
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
Returns#
Type | Description |
---|
System.Int32 | |
Type Parameters#
GetWriteSize\<T>(T[], Int32, Int32)#
Get the required size to write an unmanaged array
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | array | The array to write |
System.Int32 | count | The amount of elements to write |
System.Int32 | offset | Where in the array to start |
Returns#
Type | Description |
---|
System.Int32 | |
Type Parameters#
Seek(Int32)#
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#
Parameters#
Type | Name | Description |
---|
System.Int32 | 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#
Returns#
Type | Description |
---|
System.Byte[] | |
Truncate(Int32)#
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#
Parameters#
Type | Name | Description |
---|
System.Int32 | where | The value to truncate to. If -1, the current position will be used. |
TryBeginWrite(Int32)#
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#
Parameters#
Type | Name | Description |
---|
System.Int32 | bytes | Amount of bytes to write |
Returns#
Type | Description |
---|
System.Boolean | True if the write is allowed, false otherwise |
Exceptions#
Type | Condition |
---|
System.InvalidOperationException | If called while in a bitwise context |
TryBeginWriteInternal(Int32)#
Internal version of TryBeginWrite. Differs from TryBeginWrite only in
that it won't ever move the AllowedWriteMark backward.
Declaration#
Parameters#
Type | Name | Description |
---|
System.Int32 | bytes | |
Returns#
Type | Description |
---|
System.Boolean | |
Exceptions#
Type | Condition |
---|
System.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#
Parameters#
Type | Name | Description |
---|
T | value | The value you want to write |
Returns#
Type | Description |
---|
System.Boolean | True if the write is allowed, false otherwise |
Type Parameters#
Exceptions#
Type | Condition |
---|
System.InvalidOperationException | If called while in a bitwise context |
WriteByte(Byte)#
Write a byte to the stream.
Declaration#
Parameters#
Type | Name | Description |
---|
System.Byte | value | Value to write |
WriteBytes(Byte*, Int32, Int32)#
Write multiple bytes to the stream
Declaration#
Parameters#
Type | Name | Description |
---|
System.Byte* | value | Value to write |
System.Int32 | size | Number of bytes to write |
System.Int32 | offset | Offset into the buffer to begin writing |
WriteBytes(Byte[], Int32, Int32)#
Write multiple bytes to the stream
Declaration#
Parameters#
Type | Name | Description |
---|
System.Byte[] | value | Value to write |
System.Int32 | size | Number of bytes to write |
System.Int32 | offset | Offset into the buffer to begin writing |
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#
Parameters#
Type | Name | Description |
---|
System.Byte | value | Value to write |
WriteBytesSafe(Byte*, Int32, Int32)#
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#
Parameters#
Type | Name | Description |
---|
System.Byte* | value | Value to write |
System.Int32 | size | Number of bytes to write |
System.Int32 | offset | Offset into the buffer to begin writing |
WriteBytesSafe(Byte[], Int32, Int32)#
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#
Parameters#
Type | Name | Description |
---|
System.Byte[] | value | Value to write |
System.Int32 | size | Number of bytes to write |
System.Int32 | offset | Offset into the buffer to begin writing |
WriteNetworkSerializable\<T>(in T)#
Write an INetworkSerializable
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | The value to write |
Type Parameters#
WriteNetworkSerializable\<T>(T[], Int32, Int32)#
Write an array of INetworkSerializables
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | array | The value to write |
System.Int32 | count | |
System.Int32 | offset | |
Type Parameters#
WritePartialValue\<T>(T, Int32, Int32)#
Write a partial value. The specified number of bytes is written from the
value and the rest is ignored.
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | Value to write |
System.Int32 | bytesToWrite | Number of bytes |
System.Int32 | offsetBytes | Offset into the value to begin reading the bytes |
Type Parameters#
Exceptions#
Type | Condition |
---|
System.InvalidOperationException | |
System.OverflowException | |
WriteValue(in Color)#
Declaration#
Parameters#
Type | Name | Description |
---|
Color | value | |
WriteValue(Color[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Color[] | value | |
WriteValue(in Color32)#
Declaration#
Parameters#
Type | Name | Description |
---|
Color32 | value | |
WriteValue(Color32[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Color32[] | value | |
WriteValue(in Quaternion)#
Declaration#
Parameters#
Type | Name | Description |
---|
Quaternion | value | |
WriteValue(Quaternion[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Quaternion[] | value | |
WriteValue(in Ray)#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray | value | |
WriteValue(Ray[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray[] | value | |
WriteValue(in Ray2D)#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray2D | value | |
WriteValue(Ray2D[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray2D[] | value | |
WriteValue(String, Boolean)#
Declaration#
Parameters#
Type | Name | Description |
---|
System.String | s | The string to write |
System.Boolean | oneByteChars | Whether or not to use one byte per character. This will only allow ASCII |
WriteValue(in Vector2)#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector2 | value | |
WriteValue(Vector2[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector2[] | value | |
WriteValue(in Vector3)#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector3 | value | |
WriteValue(Vector3[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector3[] | value | |
WriteValue(in Vector4)#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector4 | value | |
WriteValue(Vector4[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector4[] | value | |
WriteValue\<T>(in T, FastBufferWriter.ForEnums)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForEnums | unused | |
Type Parameters#
WriteValue\<T>(in T, FastBufferWriter.ForNetworkSerializable)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForNetworkSerializable | unused | |
Type Parameters#
WriteValue\<T>(in T, FastBufferWriter.ForPrimitives)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForPrimitives | unused | |
Type Parameters#
WriteValue\<T>(in T, FastBufferWriter.ForStructs)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForStructs | unused | |
Type Parameters#
WriteValue\<T>(T[], FastBufferWriter.ForEnums)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForEnums | unused | |
Type Parameters#
WriteValue\<T>(T[], FastBufferWriter.ForNetworkSerializable)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForNetworkSerializable | unused | |
Type Parameters#
WriteValue\<T>(T[], FastBufferWriter.ForPrimitives)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForPrimitives | unused | |
Type Parameters#
WriteValue\<T>(T[], FastBufferWriter.ForStructs)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForStructs | unused | |
Type Parameters#
WriteValueSafe(in Color)#
Declaration#
Parameters#
Type | Name | Description |
---|
Color | value | |
WriteValueSafe(Color[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Color[] | value | |
WriteValueSafe(in Color32)#
Declaration#
Parameters#
Type | Name | Description |
---|
Color32 | value | |
WriteValueSafe(Color32[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Color32[] | value | |
WriteValueSafe(in Quaternion)#
Declaration#
Parameters#
Type | Name | Description |
---|
Quaternion | value | |
WriteValueSafe(Quaternion[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Quaternion[] | value | |
WriteValueSafe(in Ray)#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray | value | |
WriteValueSafe(Ray[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray[] | value | |
WriteValueSafe(in Ray2D)#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray2D | value | |
WriteValueSafe(Ray2D[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Ray2D[] | value | |
WriteValueSafe(String, Boolean)#
Writes a string
"Safe" version - automatically performs bounds checking. Less efficient
than bounds checking for multiple writes at once by calling
TryBeginWrite.
Declaration#
Parameters#
Type | Name | Description |
---|
System.String | s | The string to write |
System.Boolean | oneByteChars | Whether or not to use one byte per character. This will only allow ASCII |
WriteValueSafe(in Vector2)#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector2 | value | |
WriteValueSafe(Vector2[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector2[] | value | |
WriteValueSafe(in Vector3)#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector3 | value | |
WriteValueSafe(Vector3[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector3[] | value | |
WriteValueSafe(in Vector4)#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector4 | value | |
WriteValueSafe(Vector4[])#
Declaration#
Parameters#
Type | Name | Description |
---|
Vector4[] | value | |
WriteValueSafe\<T>(in T, FastBufferWriter.ForEnums)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForEnums | unused | |
Type Parameters#
WriteValueSafe\<T>(in T, FastBufferWriter.ForNetworkSerializable)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForNetworkSerializable | unused | |
Type Parameters#
WriteValueSafe\<T>(in T, FastBufferWriter.ForPrimitives)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForPrimitives | unused | |
Type Parameters#
WriteValueSafe\<T>(in T, FastBufferWriter.ForStructs)#
Declaration#
Parameters#
Type | Name | Description |
---|
T | value | |
FastBufferWriter.ForStructs | unused | |
Type Parameters#
WriteValueSafe\<T>(T[], FastBufferWriter.ForEnums)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForEnums | unused | |
Type Parameters#
WriteValueSafe\<T>(T[], FastBufferWriter.ForNetworkSerializable)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForNetworkSerializable | unused | |
Type Parameters#
WriteValueSafe\<T>(T[], FastBufferWriter.ForPrimitives)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForPrimitives | unused | |
Type Parameters#
WriteValueSafe\<T>(T[], FastBufferWriter.ForStructs)#
Declaration#
Parameters#
Type | Name | Description |
---|
T[] | value | |
FastBufferWriter.ForStructs | unused | |
Type Parameters#
Implements#