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

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

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.

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