Class Writer
Writes data to a buffer.
Inherited Members
Namespace: FishNet.Serializing
Assembly: FishNet.Runtime.dll
Syntax
public class Writer
Fields
Length
Number of bytes writen to the buffer.
Declaration
public int Length
Field Value
Type | Description |
---|---|
System.Int32 |
NetworkManager
NetworkManager associated with this writer. May be null.
Declaration
public NetworkManager NetworkManager
Field Value
Type | Description |
---|---|
NetworkManager |
Position
Current write position.
Declaration
public int Position
Field Value
Type | Description |
---|---|
System.Int32 |
UNSET_COLLECTION_SIZE_VALUE
Value used when a collection is unset, as in null.
Declaration
public const int UNSET_COLLECTION_SIZE_VALUE = -1
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
Capacity
Capacity of the buffer.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
EnsureBufferCapacity(Int32)
Ensures the buffer Capacity is of minimum count.
Declaration
public void EnsureBufferCapacity(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count |
EnsureBufferLength(Int32)
Ensure a number of bytes to be available in the buffer from current position.
Declaration
public void EnsureBufferLength(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count |
FastInsertByte(Byte, Int32)
Inserts value at index within the buffer. This method does not perform error checks.
Declaration
public void FastInsertByte(byte value, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | |
System.Int32 | index |
GetArraySegment()
Returns the used portion of the buffer as an ArraySegment.
Declaration
public ArraySegment<byte> GetArraySegment()
Returns
Type | Description |
---|---|
System.ArraySegment<System.Byte> |
GetBuffer()
Returns the buffer. The returned value will be the full buffer, even if not all of it is used.
Declaration
public byte[] GetBuffer()
Returns
Type | Description |
---|---|
System.Byte[] |
Reserve(Int32)
Reserves a number of bytes from current position.
Declaration
public void Reserve(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count |
Reset(NetworkManager)
Resets the writer as though it was unused. Does not reset buffers.
Declaration
public void Reset(NetworkManager manager = null)
Parameters
Type | Name | Description |
---|---|---|
NetworkManager | manager |
ToString()
Outputs reader to string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Write<T>(T)
Writes any supported type.
Declaration
public void Write<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value |
Type Parameters
Name | Description |
---|---|
T |
WriteArray<T>(T[])
Writes an array.
Declaration
public void WriteArray<T>(T[] value)
Parameters
Type | Name | Description |
---|---|---|
T[] | value | Collection to write. |
Type Parameters
Name | Description |
---|---|
T |
WriteArray<T>(T[], Int32)
Writes an array.
Declaration
public void WriteArray<T>(T[] value, int offset)
Parameters
Type | Name | Description |
---|---|---|
T[] | value | Collection to write. |
System.Int32 | offset | Offset to begin at. |
Type Parameters
Name | Description |
---|---|
T |
WriteArray<T>(T[], Int32, Int32)
Writes an array.
Declaration
public void WriteArray<T>(T[] value, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
T[] | value | Collection to write. |
System.Int32 | offset | Offset to begin at. |
System.Int32 | count | Entries to write. |
Type Parameters
Name | Description |
---|---|
T |
WriteArraySegment(ArraySegment<Byte>)
Writes an ArraySegment without size.
Declaration
public void WriteArraySegment(ArraySegment<byte> value)
Parameters
Type | Name | Description |
---|---|---|
System.ArraySegment<System.Byte> | value |
WriteArraySegmentAndSize(ArraySegment<Byte>)
Writes a byte ArraySegment and it's size.
Declaration
public void WriteArraySegmentAndSize(ArraySegment<byte> value)
Parameters
Type | Name | Description |
---|---|---|
System.ArraySegment<System.Byte> | value |
WriteBoolean(Boolean)
Writes a boolean.
Declaration
public void WriteBoolean(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value |
WriteByte(Byte)
Writes a byte.
Declaration
public void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value |
WriteBytes(Byte[], Int32, Int32)
Writes bytes.
Declaration
public void WriteBytes(byte[] value, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | |
System.Int32 | offset | |
System.Int32 | count |
WriteBytesAndSize(Byte[])
Writes all bytes in value and length of bytes.
Declaration
public void WriteBytesAndSize(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value |
WriteBytesAndSize(Byte[], Int32, Int32)
Writes bytes and length of bytes.
Declaration
public void WriteBytesAndSize(byte[] value, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | |
System.Int32 | offset | |
System.Int32 | count |
WriteChannel(Channel)
Writes a transport channel.
Declaration
public void WriteChannel(Channel channel)
Parameters
Type | Name | Description |
---|---|---|
Channel | channel |
WriteChar(Char)
Writes a char.
Declaration
public void WriteChar(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value |
WriteColor(Color, AutoPackType)
Writes a Color.
Declaration
public void WriteColor(Color value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Color | value | |
AutoPackType | packType |
WriteColor32(Color32)
Writes a Color32.
Declaration
public void WriteColor32(Color32 value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Color32 | value |
WriteDateTime(DateTime)
Writes a DateTime.
Declaration
public void WriteDateTime(DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt |
WriteDecimal(Decimal)
Writes a decimal.
Declaration
public void WriteDecimal(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | value |
WriteDictionary<TKey, TValue>(Dictionary<TKey, TValue>)
Writes a dictionary.
Declaration
public void WriteDictionary<TKey, TValue>(Dictionary<TKey, TValue> dict)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<TKey, TValue> | dict |
Type Parameters
Name | Description |
---|---|
TKey | |
TValue |
WriteDouble(Double)
Writes a double.
Declaration
public void WriteDouble(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value |
WriteGameObject(GameObject)
Writes a GameObject. GameObject must be spawned over the network already or be a prefab with a NetworkObject attached.
Declaration
public void WriteGameObject(GameObject go)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | go |
WriteGuidAllocated(Guid)
Writes a Guid.
Declaration
public void WriteGuidAllocated(Guid value)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | value |
WriteInt16(Int16)
Writes a int16.
Declaration
public void WriteInt16(short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | value |
WriteInt32(Int32, AutoPackType)
Writes a int32.
Declaration
public void WriteInt32(int value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | |
AutoPackType | packType |
WriteInt64(Int64, AutoPackType)
Writes an int64.
Declaration
public void WriteInt64(long value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | |
AutoPackType | packType |
WriteLayerMask(LayerMask)
Writers a LayerMask.
Declaration
public void WriteLayerMask(LayerMask value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.LayerMask | value |
WriteList<T>(List<T>)
Writes a list.
Declaration
public void WriteList<T>(List<T> value)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T> | value | Collection to write. |
Type Parameters
Name | Description |
---|---|
T |
WriteList<T>(List<T>, Int32)
Writes a list.
Declaration
public void WriteList<T>(List<T> value, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T> | value | Collection to write. |
System.Int32 | offset | Offset to begin at. |
Type Parameters
Name | Description |
---|---|
T |
WriteList<T>(List<T>, Int32, Int32)
Writes a list.
Declaration
public void WriteList<T>(List<T> value, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T> | value | Collection to write. |
System.Int32 | offset | Offset to begin at. |
System.Int32 | count | Entries to write. |
Type Parameters
Name | Description |
---|---|
T |
WriteMatrix4x4(Matrix4x4)
Writes a Matrix4x4.
Declaration
public void WriteMatrix4x4(Matrix4x4 value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Matrix4x4 | value |
WriteNetworkBehaviour(NetworkBehaviour)
Writes a NetworkBehaviour.
Declaration
public void WriteNetworkBehaviour(NetworkBehaviour nb)
Parameters
Type | Name | Description |
---|---|---|
NetworkBehaviour | nb |
WriteNetworkBehaviourId(NetworkBehaviour)
Writes a NetworkBehaviourId.
Declaration
public void WriteNetworkBehaviourId(NetworkBehaviour nb)
Parameters
Type | Name | Description |
---|---|---|
NetworkBehaviour | nb |
WriteNetworkConnection(NetworkConnection)
Writes a NetworkConnection.
Declaration
public void WriteNetworkConnection(NetworkConnection connection)
Parameters
Type | Name | Description |
---|---|---|
NetworkConnection | connection |
WriteNetworkConnectionId(Int32)
Writes a short for a connectionId.
Declaration
public void WriteNetworkConnectionId(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
WriteNetworkObject(NetworkObject)
Writes a NetworkObject.
Declaration
public void WriteNetworkObject(NetworkObject nob)
Parameters
Type | Name | Description |
---|---|---|
NetworkObject | nob |
WriteNetworkObjectId(NetworkObject)
Writes a NetworkObject.ObjectId.
Declaration
public void WriteNetworkObjectId(NetworkObject nob)
Parameters
Type | Name | Description |
---|---|---|
NetworkObject | nob |
WriteNetworkObjectId(Int32)
Writes an objectId.
Declaration
public void WriteNetworkObjectId(int objectId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | objectId |
WritePackedWhole(UInt64)
Writes a packed whole number.
Declaration
public void WritePackedWhole(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value |
WritePlane(Plane)
Writes a plane.
Declaration
public void WritePlane(Plane value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Plane | value |
WriteQuaternion(Quaternion, AutoPackType)
Writes a Quaternion.
Declaration
public void WriteQuaternion(Quaternion value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Quaternion | value | |
AutoPackType | packType |
WriteRay(Ray)
Writes a Ray.
Declaration
public void WriteRay(Ray value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | value |
WriteRay2D(Ray2D)
Writes a Ray2D.
Declaration
public void WriteRay2D(Ray2D value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray2D | value |
WriteRect(Rect)
Writes a rect.
Declaration
public void WriteRect(Rect value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Rect | value |
WriteSByte(SByte)
Writes a sbyte.
Declaration
public void WriteSByte(sbyte value)
Parameters
Type | Name | Description |
---|---|---|
System.SByte | value |
WriteSingle(Single, AutoPackType)
Writes a single (float).
Declaration
public void WriteSingle(float value, AutoPackType packType = AutoPackType.Unpacked)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | |
AutoPackType | packType |
WriteString(String)
Writes a string.
Declaration
public void WriteString(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value |
WriteTickUnpacked(UInt32)
Writes a tick without packing.
Declaration
public void WriteTickUnpacked(uint value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value |
WriteTransform(Transform)
Writes a Transform. Transform must be spawned over the network already or be a prefab with a NetworkObject attached.
Declaration
public void WriteTransform(Transform t)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Transform | t |
WriteUInt16(UInt16)
Writes a uint16.
Declaration
public void WriteUInt16(ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value |
WriteUInt32(UInt32, AutoPackType)
Writes a uint32.
Declaration
public void WriteUInt32(uint value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | |
AutoPackType | packType |
WriteUInt64(UInt64, AutoPackType)
Writes a uint64.
Declaration
public void WriteUInt64(ulong value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value | |
AutoPackType | packType |
WriteVector2(Vector2)
Writes a Vector2.
Declaration
public void WriteVector2(Vector2 value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | value |
WriteVector2Int(Vector2Int, AutoPackType)
Writes a Vector2Int.
Declaration
public void WriteVector2Int(Vector2Int value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2Int | value | |
AutoPackType | packType |
WriteVector3(Vector3)
Writes a Vector3
Declaration
public void WriteVector3(Vector3 value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | value |
WriteVector3Int(Vector3Int, AutoPackType)
Writes a Vector3Int.
Declaration
public void WriteVector3Int(Vector3Int value, AutoPackType packType = AutoPackType.Packed)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3Int | value | |
AutoPackType | packType |
WriteVector4(Vector4)
Writes a Vector4.
Declaration
public void WriteVector4(Vector4 value)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector4 | value |
ZigZagEncode(UInt64)
ZigZag encode an integer. Move the sign bit to the right.
Declaration
public ulong ZigZagEncode(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value |
Returns
Type | Description |
---|---|
System.UInt64 |