MissingReferenceException after it tries to get the player PhotonView from PunClasses
Photon returns an error after it tries to get the player PhotonView from PunClasses
#if UNITY_EDITOR
// In the editor we want to avoid caching this at design time, so changes in PV structure appear immediately.
if (!Application.isPlaying || this.pvCache == null)
{
this.pvCache = PhotonView.Get(this);
}
#else
if (this.pvCache == null)
{
this.pvCache = PhotonView.Get(this);
}
#endif
return this.pvCache;
I spawn the two players inside the Menu then keep them alive when I load the Game Scene and everything works great.
this happens after I play one match then I return to the menu scene then start a new match.
Inside the Leave match function, i have :
PhotonNetwork.LeaveRoom();
PhotonNetwork.Disconnect();
Invoke(nameof(GoToMenu), 1f);
Comments
-
Things I tried:
- Spawn the players inside the Game scene and destroy them
- set room PlayerTTL to 0 so if a user leaves the object is destroyed
- PhotonNetwork.DestroyAll before leaving a room
- Clear all RPC Cache and room Cache
- PhotonNetwork.OpRemoveCompleteCacheOfPlayer before leaving the room
- PhotonNetwork.Destroy(gameObject); before leaving the room
- PhotonNetwork.DestroyPlayerObjects(PhotonNetwork.LocalPlayer.ActorNumber); before leaving a the room
0 -
The exception should give you an exact line number, where the issue happens. Please share it and let us know which line it is and which value actually is null.
0