Exemplo n.º 1
0
        private void Start()
        {
            config = Resources.Load <PlayersConfig>("Players");
            var names = config.Players;

            var countObject = names.Length;

            if (countObject == 0)
            {
                baseButton.gameObject.SetActive(false);
                return;
            }

            baseButton.Setup(names[0], OnPlayerButton);

            for (int i = 1; i < countObject; i++)
            {
                var btn = Instantiate(baseButton, baseButton.transform.parent);
                btn.Setup(names[i], OnPlayerButton);
            }
        }
Exemplo n.º 2
0
    public void AddPlayer()
    {
        PlayerData data = new PlayerData();

        players.Add(data);
        data.playerName = "Player " + players.Count;
        GameObject newButton = GameObject.Instantiate(prefab);

        newButton.transform.SetParent(contentPanel);

        PlayerButton playerButton = newButton.GetComponent <PlayerButton>();

        playerButton.Setup(data, this);

        //old stuff
        //Player newPlayer = new Player();
        //newPlayer.name = "Player " + players.Count;
        //GameObject newButton = Instantiate(playerButton);
        //newButton.transform.SetParent(removePlayerPanel.transform);
        //newButton.GetComponent<Text>().text = newPlayer.name;
        //players.Add(newPlayer);
        //print(players.Count);
        //print(newButton.GetComponent<Player>().name);
    }