我想在连接的播放器之间发送自定义消息,为此,我参考了以下教程:
我已经编写了此类代码并进行了测试:
public class DodgelsNetworkMessages : NetworkBehaviour {
const short MESSAGE_ID = 1002;
public void SendMessage ()
{
GameHUDController.Instance.UpdateDebugMesssage ("\nSendMessage");
NetworkServer.RegisterHandler (MESSAGE_ID, OnMessageReceived);
var msg = new EmptyMessage();
// NetworkClient.allClients[0].Send (MESSAGE_ID, emtyBase);
NetworkServer.SendToAll (MESSAGE_ID, msg);
}
public void OnMessageReceived(NetworkMessage netMsg){
GameHUDController.Instance.UpdateDebugMesssage ("\nNetwork Message received...");
}
}
我无法调用OnMessageReceived方法,请给我一些建议,肯定是我做错了。