Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

NetworkWriter

class in UnityEngine.Networking

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

General purpose serializer for UNET (for serializing data to byte arrays).

Variables

PositionThe current position of the internal buffer.

Constructors

NetworkWriterCreates a new NetworkWriter object.

Public Functions

AsArrayReturns the internal array of bytes the writer is using. This is NOT a copy.
FinishMessageThis fills out the size header of a message begun with StartMessage(), so that it can be send using Send() functions.
SeekZeroSeeks to the start of the internal buffer.
StartMessageThis begins a new message, which should be completed with FinishMessage() once the payload has been written.
ToArrayReturns a copy of internal array of bytes the writer is using, it copies only the bytes used.
WriteThis writes a reference to an object, value, buffer or network message, together with a NetworkIdentity component to the stream.
WriteBytesAndSizeThis writes a 16-bit count and a array of bytes of that length to the stream.
WriteBytesFullThis writes a 16-bit count and an array of bytes of that size to the stream.
WritePackedUInt32This writes the 32-bit value to the stream using variable-length-encoding.
WritePackedUInt64This writes the 64-bit value to the stream using variable-length-encoding.