Skip to content

PlayerPrefProperty

Matheus Lessa Rodrigues edited this page Oct 28, 2017 · 1 revision

PlayerPrefProperty

A series of classes that make it easy to use and change values of PlayerPref as if they were class fields.

Example

using UnityEngine;
using BitStrap;

public sealed class MyScript : MonoBehaviour
{
	public PlayerPrefInt myIntPlayerPref = new PlayerPrefInt( "TheKeyToMyPlayerPref" );
	public PlayerPrefString myStringPlayerPref = new PlayerPrefString( "AnotherKeyToAnotherPlayerPref", "SomeDefaultValue" );
	public PlayerPrefBool myBoolPlayerPref = new PlayerPrefBool( "OneMoreKeyToMyPlayerPref" );
	public PlayerPrefFloat myFloatPlayerPref = new PlayerPrefFloat( "TheLastKeyToMyPlayerPref" );

	private Start()
	{
		myIntPlayerPref.Value = 17; // Write values to PlayerPref
		Debug.Log( myStringPlayerPref.Value ); // Read values from PlayerPref
	}
}
Clone this wiki locally