public static void RequestTeam(this PhotonPlayer player) { #if (UNITY_EDITOR) if (!PhotonNetwork.connectedAndReady) { Debug.LogWarning("JoinTeam was called in state: " + PhotonNetwork.connectionStateDetailed + ". Not connectedAndReady."); return; } #endif TeamID newTeam = player.GetTeam(); int maxIterations = TeamData.GetMaxTeams(PhotonNetwork.room.MaxPlayers); do { if (maxIterations <= 0) { newTeam = TeamID.NotSet; break; } maxIterations--; newTeam = TeamData.GetNextTeam(newTeam); #if (UNITY_EDITOR) Debug.Log(newTeam); #endif } while(RoomTeams.PlayersPerTeam[newTeam].Count >= TeamData.GetMaxPlayersPerTeam(PhotonNetwork.room.MaxPlayers)); if (newTeam == TeamID.NotSet) { #if (UNITY_EDITOR) Debug.Log("ERROR: No empty team found!"); #endif } else { player.SetCustomProperties(new Hashtable() { { RoomTeams.TeamPlayerProp, (byte)newTeam } }); } }