新的光子网络,我使用提高事件为我的棋盘游戏。有时事件不会引发,但大多数情况下,他们都很好的需要帮助。
private void OnEnable() {
PhotonNetwork.NetworkingClient.EventReceived += NetworkingClient_EventReceived;
}
private void Disable()
{
PhotonNetwork.NetworkingClient.EventReceived -= NetworkingClient_EventReceived;
}
private void NetworkingClient_EventReceived(EventData obj)
{
byte eventCode = obj.Code;
if (eventCode == (byte)EnumGame.DiceRoll)
{
EventManager.instance.rolldiceEvent(obj);
}
if (eventCode == (byte)EnumGame.DiceNumber)
{
EventManager.instance.displaydiceNumber(obj);
}
if (eventCode == (byte)EnumGame.Passdice)
{
EventManager.instance.passdicetootherPlayer(obj);
}
if (eventCode == (byte)EnumGame.PassTurn)
{
EventManager.instance.passturntootherPlayer(obj);
}
}这是我在脚本中用来引发事件的方式,我没有得到任何异常:
object[] data = new object[] { Photonplayer.instance.getplayerId() };
RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others };
PhotonNetwork.RaiseEvent((byte)EnumGame.Passdice, data, raiseEventOptions, SendOptions.SendUnreliable);发布于 2022-02-27 16:30:58
object[] data = new object[] { Photonplayer.instance.getplayerId() };
RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others };
PhotonNetwork.RaiseEvent((byte)EnumGame.Passdice, data, raiseEventOptions, SendOptions.SendReliable);在RaiseEvent的第四个参数中将"SendOptions.SendUnreliable“更改为"SendOptions.SendReliable”。
https://stackoverflow.com/questions/62970830
复制相似问题