Advertisement
gandalfbialy

Untitled

Jul 19th, 2025
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. public override void OnDisconnected(DisconnectCause cause)
  2.     {
  3.         networkText.text = $"Disconnected: {cause}";
  4.         isConnecting = false;
  5.     }
  6.  
  7.     public override void OnJoinRandomFailed(short returnCode, string message)
  8.     {
  9.         networkText.text = "No random room available. Creating one...";
  10.         // Create a new room with the specified max players
  11.         RoomOptions options = new RoomOptions
  12.         {
  13.             MaxPlayers = maxPlayersPerRoom
  14.         };
  15.         PhotonNetwork.CreateRoom(null, options);
  16.     }
  17.  
  18.     public override void OnCreatedRoom()
  19.     {
  20.         networkText.text = "Room created. Waiting for players...";
  21.     }
  22.  
  23.     public override void OnJoinRoomFailed(short returnCode, string message)
  24.     {
  25.         networkText.text = $"Failed to join room: {message}";
  26.     }
  27.  
  28.     public override void OnJoinedRoom()
  29.     {
  30.         networkText.text = "Joined room! Loading race scene…";
  31.         // Only the MasterClient will control scene loading
  32.         PhotonNetwork.LoadLevel("Game");
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement