Here is a Sample Code For StaticPlayerPrefs

using UnityEngine;

public class StaticPlayerPrefs
{
    public static string ExampleString
    {
        get { return PlayerPrefs.GetString("STPP-ExampleString"); }
        set { PlayerPrefs.SetString("STPP-ExampleString", value); }
    }
    public static int ExampleInt
    {
        get { return PlayerPrefs.GetInt("STPP-ExampleInt"); }
        set { PlayerPrefs.SetInt("STPP-ExampleInt", value); }
    }
    public static float ExampleFloat
    {
        get { return PlayerPrefs.GetFloat("STPP-ExampleFloat"); }
        set { PlayerPrefs.SetFloat("STPP-ExampleFloat", value); }
    }
    public static bool ExampleBool
    {
        get 
        {
            if (PlayerPrefs.GetString("STPP-ExampleBool") == "TRUE")
                return true;
            else
                return false;
        }
        set 
        {
            if (value)
                PlayerPrefs.SetString("STPP-ExampleBool", "TRUE");
            else
                PlayerPrefs.SetString("STPP-ExampleBool", "FALSE");
        }
    }
}

Leave a Reply

Your email address will not be published.