- Home /
Question by
tejasrj · Jun 13, 2015 at 07:16 PM ·
playerprefs
PlayerPrefs.GetInt before game stop play
can we update PlayerPrefs.GetInt during running game
i am trying to make life apple if apple is >= 1 then save me button to work but player pref is not working
Comment
here is my script
public class AppleCount : $$anonymous$$onoBehaviour { //
public static int apple ; public static int Subapple ;
Text text;
void Start () {
text = GetComponent<Text>();
apple = PlayerPrefs.GetInt("apple");
}
void Awake () {
text = GetComponent<Text>();
}
void Update () {
PlayerPrefs.Save();
text.text = "Apple : " + apple ;
}
public void Increaseapple (int amount)
{
//Subapple += amount;
//PlayerPrefs.GetInt ("apple") -= appleValue;
apple += amount;
Subapple += apple;
Save ();
}
void Save()
{
PlayerPrefs.SetInt ("apple" ,apple );
PlayerPrefs.SetInt ("Subapple", Subapple);
//PlayerPrefs.Save();
//PlayerPrefs.Save();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613200940im_/https://answers.unity.com/themes/thub/images/avi.jpg)