NullReferenceException when using room.Name in OnCreatedRoom() .

I am getting NullReferenceException when using PhotonNetwork.room.Name in OnCreatedRoom() .
Sample code:
{
TypedLobby tournamentStageLobby = new TypedLobby("TournamentStage", LobbyType.SqlLobby);
PhotonNetwork.JoinLobby(tournamentStageLobby);
bool response = PhotonNetwork.JoinOrCreateRoom("892734897238947298374yoyoyoyo", newRoomOptions, tournamentStageLobby);
}

public override void OnCreatedRoom()
{
Debug.Log("OnCreatedRoom" + PhotonNetwork.room.Name); // Error in this line

}

Comments

  • Hi @Okhla,

    when OnCreatedRoom is called on your client, this just means that the room has been created. At this point the client hasn't entered / joined the room. Please also implement the OnJoinedRoom callback. If this one gets called, PhotonNetwork.room.Name should be available as well.
Sign In or Register to comment.