public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); Debug.Log("Server Add Player"); Debug.Log($"Connection is {conn.connectionId}"); ClientOnConnected?.Invoke(conn); PlayerReadyBar readyBar = null; GameObject readyBarParent = null; int i = 1; // Loop until fetching a free ready bar slot while (i <= 10) { string nodeName = $"/PlayerBoxes/Panel/Player ({i})"; readyBarParent = GameObject.Find(nodeName); Debug.Log($"Finding node {nodeName}: {readyBarParent}"); Debug.Log($"Children are {readyBarParent.transform.GetChild(0)}"); readyBar = readyBarParent.GetComponentInChildren <PlayerReadyBar>(true); Debug.Log("Setting ready bar to active"); readyBar.ServerToggleParentActive(true); Debug.Log($"Trying {nodeName} to see if free, id is {readyBar.GetPlayerId()}"); int currentClientId = readyBar.GetPlayerId(); if (currentClientId == -1) { Debug.Log($"Setting {nodeName} to player {conn.connectionId}"); readyBar.SetPlayerId(conn.connectionId); break; } i++; } }
public override void OnClientConnect(NetworkConnection conn) { base.OnClientConnect(conn); ClientOnConnected?.Invoke(); }