- Home /
PlayerPrefs dont worn android
I added PlayerPrefs to my script and everything works fine in unity editor byt when i build it into apk it doesnt saving or loading any data.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Click : MonoBehaviour {
public UnityEngine.UI.Text Diamenty;
public UnityEngine.UI.Text GPC;
public UnityEngine.UI.Text TotalClicked123;
public UnityEngine.UI.Text TotalMaked123;
public float gold = 0.00f;
public float goldperclick = 1;
public int totalClicked = 0;
public float totalMaked = 0;
public bool buyed;
public bool paused;
void Start(){
//PlayerPrefs.DeleteAll ();
Load();
}
void Update()
{
if (paused == true) {
PlayerPrefs.SetFloat ("GoldKey", gold);
PlayerPrefs.SetFloat ("GoldPerClickKey", goldperclick);
}
Diamenty.text = gold + "\nMemes";
GPC.text = goldperclick + "/click";
TotalClicked123.text = totalClicked + "";
TotalMaked123.text = totalMaked + "";
}
public void Clicked() { gold += goldperclick; totalClicked++; totalMaked = totalMaked + goldperclick; PlayerPrefs.SetFloat ("GoldKey", gold); PlayerPrefs.SetFloat ("GoldPerClickKey", goldperclick); PlayerPrefs.Save ();
}
public void Load(){
gold = PlayerPrefs.GetFloat ("GoldKey", 0);
goldperclick = PlayerPrefs.GetFloat ("GoldPerClickKey", 1);
}
void OnApplicationPause(bool pause){
paused = pause;
}
}
Your answer
Follow this Question
Related Questions
is it safe to save info in PlayerPrefs? 2 Answers
How can unity user send me their PlayerPrefs? 1 Answer
Why PlayerPrefs not working although I use "HasKey" and Save() on android? 0 Answers
Does Android delete PlayerPrefs when Updating the App? 2 Answers
Is it okay to store many player preferences for mobile? 1 Answer