コード例 #1
0
    //Callbacks
    private void OnHighscoresUpdated()
    {
        HideScores();

        m_CurrentNumberOfHighscores = m_HighscoreSystem.GetNumberOfHighscores;

        for (int i = 0; i < m_CurrentNumberOfHighscores; ++i)
        {
            if (i >= m_HighscoreLabels.Count)
            {
                HighscoreLabelUI newLabel = Instantiate <HighscoreLabelUI>(m_HighscoreLabelUIPrefab, transform);
                m_HighscoreLabels.Add(newLabel);
            }

            m_HighscoreLabels[i].UpdateScore(m_HighscoreSystem.GetHighscore(i));
        }

        HideInfo();
        ShowScores();
    }
コード例 #2
0
    private void Awake()
    {
        m_HighscoreLabels = new List <HighscoreLabelUI>();

        //There should be only 1 child, and this is the one we're going to use as a "prefab"
        if (transform.childCount < 0)
        {
            Debug.LogWarning("The highscore table should have 1 child. This will be the score label template.", this);
        }

        m_HighscoreLabelUIPrefab = transform.GetChild(0).GetComponent <HighscoreLabelUI>();

        if (m_HighscoreLabelUIPrefab == null)
        {
            Debug.LogWarning("No 'HighscoreLabelUI' found on label template!", this);
        }
        else
        {
            m_HighscoreLabels.Add(m_HighscoreLabelUIPrefab);
        }

        HideInfo();
        HideScores();
    }