Help me. NullReference exception : streamBuffer ourStream and customobject error!

Options
Hello. i am learning programming and photon PUN.
I am working simple game with Unity2017.
when i finish the game, i leave a room and join room again.
through the lobby, i first join random room, then if no room exists, i make a room.
the problem is this!
when i join or make a game room( after finishing game and leaving room) , making room is fine but onjoinedroom() cannot be connected ( it worked fine in the last game)
it make a room and even cannot get in there!

The error is this :

NullReferenceException: Object reference not set to an instance of an object
CustomTypes.SerializePhotonPlayer (ExitGames.Client.Photon.StreamBuffer outStream, System.Object customobject) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/CustomTypes.cs:144)
ExitGames.Client.Photon.Protocol16.SerializeArray (ExitGames.Client.Photon.StreamBuffer dout, System.Array serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2 parameters)
ExitGames.Client.Photon.Protocol16.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType)
ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opCode, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt)
ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType)
ExitGames.Client.Photon.PeerBase.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypted)
ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable, Byte channelId)
ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable)
LoadBalancingPeer.OpJoinRoom (.EnterRoomParams opParams) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs:291)
NetworkingPeer.OpJoinRoom (.EnterRoomParams opParams) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:934)
NetworkingPeer.OnOperationResponse (ExitGames.Client.Photon.OperationResponse operationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1711)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)

i think playerId or something is missing. but i dont know what to do to solve this problem.

i am sorry , im still learning it so i am not good at programming. i need your help.
Thank you,,,

Answers

  • Hi @Senma,

    how exactly does your call order looks like when leaving the first room? I guess you have implemented OnLeftRoom() callback and use that function in order to create a new room at this point, don't you? If so, please try using another callback, for example OnJoinedLobby.

    If you have enabled autoJoinLobby by either setting the option in the PhotonServerSettings or by setting PhotonNetwork.autoJoinLobby to true in code, this callback gets called directly after OnLeftRoom. If you don't have enabled autoJoinLobby you can call PhotonNetwork.JoinLobby() from the OnLeftRoom callback in order to join the lobby. When inside the lobby, creating rooms shouldn't fail any longer.
  • Senma
    Options
    Hi @Christian_Simon ,

    Thanks! i will try.
    Have a Nice day. :3