Skip to content

Instantly share code, notes, and snippets.

@srcnalt
Created March 14, 2019 17:45
Show Gist options
  • Save srcnalt/28daef411ac6c36f68233d1db3127f5e to your computer and use it in GitHub Desktop.
Save srcnalt/28daef411ac6c36f68233d1db3127f5e to your computer and use it in GitHub Desktop.
/*
To be able to use these you need to create an object instance of Player prefs then call the get/set extention methods.
*/
using UnityEngine;
public static class ExtensionMethods
{
public static void SetBool(this PlayerPrefs pref, string key, bool value)
{
PlayerPrefs.SetInt(key, value ? 1 : 0);
}
public static bool GetBool(this PlayerPrefs pref, string key)
{
return PlayerPrefs.GetInt(key) == 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment