Legacy Documentation: Version 2017.2 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

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

NetworkReader

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 reading byte arrays).

This class works with NetworkWriter and is used for serializing data for UNet commands, RPC calls, events and low level messages.

Properties

LengthThe current length of the buffer.
PositionThe current position within the buffer.

Constructors

NetworkReaderCreates a new NetworkReader object.

Public Methods

ReadBooleanReads a boolean from the stream.
ReadByteReads a byte from the stream.
ReadBytesReads a number of bytes from the stream.
ReadBytesAndSizeThis read a 16-bit byte count and a array of bytes of that size from the stream.
ReadCharReads a char from the stream.
ReadColorReads a unity Color objects.
ReadColor32Reads a unity color32 objects.
ReadDecimalReads a decimal from the stream.
ReadDoubleReads a double from the stream.
ReadGameObjectReads a reference to a GameObject from the stream.
ReadInt16Reads a signed 16 bit integer from the stream.
ReadInt32Reads a signed 32bit integer from the stream.
ReadInt64Reads a signed 64 bit integer from the stream.
ReadMatrix4x4Reads a unity Matrix4x4 object.
ReadMessageThis is a utility function to read a typed network message from the stream.
ReadNetworkHash128Reads a NetworkHash128 assetId.
ReadNetworkIdReads a NetworkInstanceId from the stream.
ReadNetworkIdentityReads a reference to a NetworkIdentity from the stream.
ReadPackedUInt32Reads a 32-bit variable-length-encoded value.
ReadPackedUInt64Reads a 64-bit variable-length-encoded value.
ReadPlaneReads a unity Plane object.
ReadQuaternionReads a Unity Quaternion object.
ReadRayReads a Unity Ray object.
ReadRectReads a Unity Rect object.
ReadSByteReads a signed byte from the stream.
ReadSceneIdReads a NetworkSceneId from the stream.
ReadSingleReads a float from the stream.
ReadStringReads a string from the stream. (max of 32k bytes).
ReadTransformReads a reference to a Transform from the stream.
ReadUInt16Reads an unsigned 16 bit integer from the stream.
ReadUInt32Reads an unsigned 32 bit integer from the stream.
ReadUInt64Reads an unsigned 64 bit integer from the stream.
ReadVector2Reads a Unity Vector2 object.
ReadVector3Reads a Unity Vector3 objects.
ReadVector4Reads a Unity Vector4 object.
SeekZeroSets the current position of the reader's stream to the start of the stream.
ToStringReturns a string representation of the reader's buffer.

Did you find this page useful? Please give it a rating: