public bool SendWriter (Networking.NetworkWriter writer, int channelId);

Parameters

writer 包含要发送的数据的编写器对象。
channelId 用于发送数据的传输通道。

Returns

bool 如果数据已发送,则为 ture。

Description

此函数在连接上发送 NetworkWriter 对象的内容。

下面的示例会构造一个编写器并在连接上发送。


using UnityEngine;
using UnityEngine.Networking;

public class ExampleScript : MonoBehaviour { public bool Send(short msgType, MessageBase msg, NetworkConnection conn) { NetworkWriter writer = new NetworkWriter(); writer.StartMessage(8888); msg.Serialize(writer); writer.FinishMessage(); return conn.SendWriter(writer, Channels.DefaultReliable); } }