https://github.com/murphyne/playerprefswrapper
This is a wrapper for the UnityEngine.PlayerPrefs API
https://github.com/murphyne/playerprefswrapper
unity unity-asset unity3d
Last synced: about 1 month ago
JSON representation
This is a wrapper for the UnityEngine.PlayerPrefs API
- Host: GitHub
- URL: https://github.com/murphyne/playerprefswrapper
- Owner: murphyne
- Created: 2022-05-08T09:47:08.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-06-13T15:40:20.000Z (about 1 year ago)
- Last Synced: 2025-06-13T16:53:15.418Z (about 1 year ago)
- Topics: unity, unity-asset, unity3d
- Language: C#
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PlayerPrefs Wrapper
This is a wrapper for the [UnityEngine.PlayerPrefs API][PlayerPrefs].
[PlayerPrefs]:
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
## Features
- 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.
## Installation
- 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][UPM-Git] page.
- To install from a tarball file:
- Download the .tgz file from [Releases][Releases].
- Follow the instructions on the [Install a UPM package from a local tarball file][UPM-Tarball] page.
[Releases]:
https://github.com/murphyne/PlayerPrefsWrapper/releases
[UPM-Tarball]:
https://docs.unity3d.com/Manual/upm-ui-tarball.html
[UPM-Git]:
https://docs.unity3d.com/Manual/upm-ui-giturl.html
## Usage
```csharp
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;
}
```