From 24c001dcc763b6e87eb58cff1971dcac9a3751b6 Mon Sep 17 00:00:00 2001 From: Fangh Date: Thu, 29 Feb 2024 22:45:37 +0100 Subject: [PATCH] fix(GameManager): give a default value to lastState just in case --- Assets/Scripts/GameManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index bc2dd8c..89b153c 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -297,6 +297,8 @@ public void StartGame() /// private void OnRoomUpdate(object sender, ValueChangedEventArgs e) { + GameState lastState = myRoom != null ? (GameState)myRoom.currentState : GameState.EnteringName; + try { if (e?.Snapshot?.GetRawJsonValue() != null) @@ -316,7 +318,6 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) return; } - GameState lastState = (GameState)myRoom.currentState; Debug.Log($"lasState = {lastState}. Currentstep = {(GameState)myRoom.currentState}", this); if (myRoom.currentState != (int)lastState)