コード例 #1
0
    private void LoadPlayerList()
    {
        //remove old listed objects before listing new ones
        DestroyListedPlayers();

        bool loaded = ProgressController.LoadPlayerList();

        if (loaded && AppController.instance.allPlayerProgressData.playersList.Count > 0)
        {
            GameObject enabledButton;

            //reload all again
            foreach (Player iterator in AppController.instance.allPlayerProgressData.playersList)
            {
                if (iterator.PlayerID == AppController.instance.currentPlayer.PlayerID)
                {
                    enabledButton = prefabButtonCurrentPlayer;
                }
                else
                {
                    enabledButton = prefabPlayerSelectButton;
                }

                enabledButton.GetComponentInChildren <TextMeshProUGUI>().text = iterator.PlayerName;
                enabledButton.GetComponent <Button>().interactable            = true;
                enabledButton.name = iterator.PlayerID.ToString();
                Instantiate(enabledButton, prefabPlayerList.transform);
            }
        }
        else
        {
            GameObject disabledButton = prefabPlayerSelectButton;
            disabledButton.GetComponent <Button>().interactable            = false;
            disabledButton.GetComponentInChildren <TextMeshProUGUI>().text = "Player List Not Found";
            Instantiate(disabledButton, prefabPlayerList.transform);
        }

        ShowProgressInfoForCurrentPlayer();
    }