###困っていること
同じルームに入っているが、Photonを用いた変数同期ができない
下記プログラムでは受信側の「受信しますた」というログが表示されない。
接続まではできるのだが、ルームに入ったあとにエラーが出てきてしまい、プログラムが止まる。
###環境
Unity 2017.4.1.f1
OS windows10
同一のパソコン上でサーバー側をエディタで可動させ、クライアント側をビルドしたexeで動かしています。
このスクリプトがアタッチされているプレハブはAssets直下のResourcesフォルダに入れてあります。
###プログラムの内容
お互いのプログラムをスクリプトを使って同じルームに接続(debug.logにて双方確認済み)
別のスクリプトを使ってクライアント側から変数Arrowを送信し、サーバー側で受信して変数arrowに格納後、Debug.Logに受信成功の表示。
いわゆる変数同期です。
以下に送信側と受信側のプログラムとエラー表示を示します。
lang
1//受信側 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5 6public class ArrowRecever : Photon.MonoBehaviour { 7 public int arrow=0; 8 9 void OnPhotoSerializeView(PhotonStream stream, PhotonMessageInfo info) 10 { 11 if (stream.isWriting) { 12 //受信のみなので何もしない 13 } else { 14 this.arrow = (int)stream.ReceiveNext (); 15 Debug.Log ("受信しますた"); 16 } 17 } 18 19 void Update(){ 20 Debug.Log (arrow); 21 } 22}
lang
1//送信側 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5 6public class ArrowSender : Photon.MonoBehaviour { 7 private int Arrow=1001; 8 9 void OnPhotoSerializeView(PhotonStream stream, PhotonMessageInfo info) 10 { 11 if (stream.isWriting) { 12 stream.SendNext (Arrow); 13 } else { 14 //送信のみなので何もしない 15 } 16 } 17}
lang
1The observed monobehaviour (ArrowRecever) of this PhotonView does not implement OnPhotonSerializeView()! 2UnityEngine.Debug:LogError(Object) 3PhotonView:ExecuteComponentOnSerialize(Component, PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:544) 4PhotonView:SerializeComponent(Component, PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:457) 5PhotonView:SerializeView(PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:352) 6NetworkingPeer:OnSerializeWrite(PhotonView) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4243) 7NetworkingPeer:RunViewUpdate() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4105) 8PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:165) 9
lang
1The observed monobehaviour (PhotonManagerServer) of this PhotonView does not implement OnPhotonSerializeView()! 2UnityEngine.Debug:LogError(Object) 3PhotonView:ExecuteComponentOnSerialize(Component, PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:544) 4PhotonView:SerializeComponent(Component, PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:457) 5PhotonView:SerializeView(PhotonStream, PhotonMessageInfo) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:352) 6NetworkingPeer:OnSerializeWrite(PhotonView) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4243) 7NetworkingPeer:RunViewUpdate() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4105) 8PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:165) 9
以上です。よろしくおねがいします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。