fix(gamemanager): subscribe only after room is created

This commit is contained in:
Fangh 2024-02-29 22:06:16 +01:00
parent b9c1d74943
commit dc20e8e87e
1 changed files with 3 additions and 2 deletions

View File

@ -207,11 +207,12 @@ public class GameManager : MonoBehaviour
else
{
myOnlineRoom = realtimeDB.Child("rooms").Child(_code);
//subscribe to it
myOnlineRoom.ValueChanged += OnRoomUpdate;
//if room exists, join it
JoinRoom(() =>
{
//subscribe to it
myOnlineRoom.ValueChanged += OnRoomUpdate;
myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin;
players.Add(currentPlayer);