コード例 #1
0
    void OnGUI()
    {
        playerName = GUI.TextField(new Rect(Screen.width / 2 - 100f, Screen.height / 2 - 200f, 200f, 25f), playerName, 10);

        if (!savingDone)
        {
            if (GUI.Button(new Rect(Screen.width / 2 - 50f, Screen.height / 2 - 150f, 100f, 25f), "Save Score!"))
            {
                PlayerPrefs.SetFloat(playerName, playerScore);

                string playerList = PlayerPrefs.GetString("playerList");
                if (!playerList.Contains(playerName))
                {
                    playerList = playerList + playerName + "|";
                }
                PlayerPrefs.SetString("playerList", playerList);

                st.UpdateScore();
                savingDone = true;
            }
        }
    }