Example #1
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        LobbyPlayer lp = (LobbyPlayer)Instantiate(LobbyPlayerPrefab).GetComponent <LobbyPlayer>();

        lp.transform.SetParent(UI.list.transform, false);

        lp.connectionId = conn.connectionId;

        if (adminId < 0 || players.Count < 1)
        {
            adminId = lp.connectionId;
        }

        lp.colorIndex = NextAvailableColor(0);

        players.Add(lp);
        connections.Add(conn, playerControllerId);
        NetworkServer.SpawnWithClientAuthority(lp.gameObject, conn);
        lp.RpcGetNameFromInput();
    }