This is a wrapper for the UnityEngine.PlayerPrefs API.
- Cleaner syntax for working with the PlayerPrefs API.
- Type safety for saving and retrieving data.
- Support for multiple data types, including int, float, string, bool.
-
To install from a Git URL:
- Copy Git URL:
https://github.com/murphyne/PlayerPrefsWrapper.git?path=Packages/PlayerPrefsWrapper
- Follow the instructions on the Install a UPM package from a Git URL page.
- Copy Git URL:
-
To install from a tarball file:
- Download the .tgz file from Releases.
- Follow the instructions on the Install a UPM package from a local tarball file page.
using PlayerPrefsWrapper;
public class Options
{
// Create an instance of wrapped PlayerPrefs value.
// Specify a key and an optional default value.
private readonly PlayerPrefBool _option1 = new PlayerPrefBool("Option1", true);
// Get value from PlayerPrefs.
public bool GetOption1() => _option1.Value;
// Set value to PlayerPrefs.
public void SetOption1(bool value) => _option1.Value = value;
}