Version: 2017.4
LanguageEnglish
  • C#
  • JS

Script language

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

NetworkWriter.Write

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

public method Write(value: char): void;
public void Write(char value);
public method Write(value: byte): void;
public void Write(byte value);
public method Write(value: sbyte): void;
public void Write(sbyte value);
public method Write(value: short): void;
public void Write(short value);
public method Write(value: ushort): void;
public void Write(ushort value);
public method Write(value: int): void;
public void Write(int value);
public method Write(value: uint): void;
public void Write(uint value);
public method Write(value: long): void;
public void Write(long value);
public method Write(value: ulong): void;
public void Write(ulong value);
public method Write(value: float): void;
public void Write(float value);
public method Write(value: double): void;
public void Write(double value);
public method Write(value: Decimal): void;
public void Write(Decimal value);
public method Write(value: string): void;
public void Write(string value);
public method Write(value: bool): void;
public void Write(bool value);
public method Write(buffer: byte[], count: int): void;
public void Write(byte[] buffer, int count);
public method Write(buffer: byte[], offset: int, count: int): void;
public void Write(byte[] buffer, int offset, int count);
public method Write(value: Vector2): void;
public void Write(Vector2 value);
public method Write(value: Vector3): void;
public void Write(Vector3 value);
public method Write(value: Vector4): void;
public void Write(Vector4 value);
public method Write(value: Color): void;
public void Write(Color value);
public method Write(value: Color32): void;
public void Write(Color32 value);
public method Write(value: GameObject): void;
public void Write(GameObject value);
public method Write(value: Quaternion): void;
public void Write(Quaternion value);
public method Write(value: Rect): void;
public void Write(Rect value);
public method Write(value: Plane): void;
public void Write(Plane value);
public method Write(value: Ray): void;
public void Write(Ray value);
public method Write(value: Matrix4x4): void;
public void Write(Matrix4x4 value);
public method Write(msg: Networking.MessageBase): void;
public void Write(Networking.MessageBase msg);
public method Write(value: Networking.NetworkHash128): void;
public void Write(Networking.NetworkHash128 value);
public method Write(value: Networking.NetworkIdentity): void;
public void Write(Networking.NetworkIdentity value);
public method Write(value: Networking.NetworkInstanceId): void;
public void Write(Networking.NetworkInstanceId value);
public method Write(value: Networking.NetworkSceneId): void;
public void Write(Networking.NetworkSceneId value);
public method Write(value: Transform): void;
public void Write(Transform value);

Parameters

valueThe object to write.
bufferThe byte buffer to write.
countThe number of bytes in the byte buffer to write.
offsetThe byte buffer array element to start writing from.
msgThe network message to write.

Description

This writes a reference to an object, value, buffer or network message, together with a NetworkIdentity component to the stream.

no example available in JavaScript
using UnityEngine;
using UnityEngine.Networking;

public class ExampleScript : MonoBehaviour { void Start() { short myMsgType = 444;

NetworkWriter writer = new NetworkWriter(); writer.StartMessage(myMsgType); writer.Write("test data"); writer.FinishMessage(); } }

See NetworkWriting for another code example.