How to save player score? (C#)
Creating a small browser game, need a way to save the players score, as well as from scene to scene where the score is reset, i need it to keep its value, i cant set the floats as statics, i have about 10 scripts all of which are linked to eachother so i can get any values i need since ive had problems with static variables before, i just need a way that will not delete the score and level traveling from scene to scene and save the data so when they player comes back they dont loose their progress, i set up a AutoSave type of thing that will save every 5 seconds and log when it does, of coarse this is just for testing and will later be set to 5+ minutes to autosave. Ive tried looking at several tutorials all of which have been unsuccesful :(
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public class SaveLoad : MonoBehaviour {
public Player playerScript;
IEnumerator AutoSave(){
yield return new WaitForSeconds (5);
PlayerPrefs.SetFloat ("score", playerScript.Score);
PlayerPrefs.SetFloat ("level", playerScript.Level);
StartCoroutine (AutoSave ());
print ("Saved");
}
void Start () {
StartCoroutine (AutoSave ());
}
void Update(){
PlayerPrefs.GetFloat ("score");
PlayerPrefs.GetFloat ("level");
}
}