回答編集履歴

1

偽情報の訂正

2022/09/12 06:17

投稿

aiueoao
aiueoao

スコア146

test CHANGED
@@ -1,14 +1,16 @@
1
1
  MeshRenderer mesh への参照がStart()にて自分自身しかとれておらず,後から入室したクライアントでNullReferenceExceptionが出てるのだと思います.
2
- なのでIsMineの前でmeshの参照をとっておくと行けると思います.
2
+ ~~なのでIsMineの前でmeshの参照をとっておくと行けると思います.~~
3
+ すみません間違えでしたので訂正してお詫び申し上げます.
4
+ ネットワークオブジェクトが生成された時のコールバックでmesh参照を取得するべきでした.
3
5
  ```
6
+ public class ColorChange : MonoBehaviour,IPunInstantiateMagicCallback
7
+ {
4
- void Start()
8
+ public MeshRenderer mesh;
9
+
10
+ public void OnPhotonInstantiate(PhotonMessageInfo info)
5
11
  {
6
- mesh = GetComponent<MeshRenderer>();
12
+ mesh= GetComponent<MeshRenderer>();
13
+ }
7
14
 
8
- if (this.GetComponent<PhotonView>().IsMine)
9
- {
15
+
10
- mesh.material.color = mesh.material.color - new Color32(0, 0, 0, 0);
11
- this.GetComponent<PhotonView>().RPC("Transparent", RpcTarget.AllBuffered);
12
- }
13
- }
14
16
  ```