Sets the value of the preference identified by key
.
PlayerPrefs.SetFloat("Player Score", 10.0);
//This script sets the float up in the PlayerPrefs to be used elsewhere. Use GetFloat to return the settings.
using UnityEngine; using UnityEngine.SceneManagement;
public class Example : MonoBehaviour { void Start() { //Give the PlayerPrefs some values to send over PlayerPrefs.SetFloat("Health", 50.0F); }
void OnGUI() { //Create a button which loads the appropriate level when you press it if (GUI.Button(new Rect(100, 200, 200, 60), "Next Scene")) { SceneManager.LoadScene("Scene2"); } } }
no example available in JavaScript
no example available in C#
Did you find this page useful? Please give it a rating: