Version: 2017.1
public void StartMessage (short msgType);

参数

msgType 消息类型。

描述

此函数启用新消息,写入有效负载后,应使用 FinishMessage() 完成此消息。

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(); NetworkClient myClient = new NetworkClient(); myClient.Send(writer, 0); } }