Save information Unity C#

PHOTO EMBED

Thu Nov 04 2021 19:02:43 GMT+0000 (UTC)

Saved by @miguel9177 #c#

  void OnGUI()
    {
        GUI.Label(new Rect(0, 0, 100, 50), "Score " + score + volume + player);
        if (GUI.Button(new Rect(10, 50, 200, 20), "Save"))
        {
            PlayerPrefs.SetInt("score", 50);
            PlayerPrefs.SetFloat("volume", 0.9f);
            PlayerPrefs.SetString("username", "kkas");
            PlayerPrefs.Save();
        }
        if (GUI.Button(new Rect(10, 10, 200, 20), "Load"))
        {
            score = PlayerPrefs.GetInt("score");
            volume = PlayerPrefs.GetFloat("volume");
            player = PlayerPrefs.GetString("username");
        }
    }
content_copyCOPY

this script creates 2 buttons and lets me save information and load it