public override void OnRoomServerDisconnect(NetworkConnection conn) { Debug.Log($"Client has disconnected with {conn.connectionId}"); if (SceneManager.GetActiveScene().name == "RoomScene") { ClientOnDisconnected?.Invoke(conn); PlayerReadyBar readyBar = null; GameObject readyBarParent = null; int i = 1; // Loop until fetching a free ready bar while (i <= 10) { string nodeName = $"/PlayerBoxes/Panel/Player ({i})"; readyBarParent = GameObject.Find(nodeName); readyBar = readyBarParent.GetComponentInChildren <PlayerReadyBar>(true); Debug.Log($"Trying {nodeName} to see if free"); int currentClientId = readyBar.GetPlayerId(); if (currentClientId == conn.connectionId) { Debug.Log("Setting ready bar to deactive"); readyBar.ServerToggleParentActive(false); Debug.Log($"Setting {nodeName} to -1"); readyBar.SetPlayerId(-1); break; } i++; } } base.OnRoomServerDisconnect(conn); }
public override void OnClientDisconnect(NetworkConnection conn) { base.OnClientDisconnect(conn); ClientOnDisconnected?.Invoke(); }