Question by
RoyalDio2 · Aug 06, 2016 at 09:11 PM ·
c#unity 5load scene
click idle and i use PlayerPrefs
hello guys i need Little help i make click idle and i use PlayerPrefs to save and load but after start game all cost go to 0 ther is C#
public float cost;
void Start ()
{
OnLoad();
}
public void OnLoad()
{
cost = PlayerPrefs.GetFloat ("cost");
}
after start game cost go to 0 :/
Thank you for understanding
test.png
(12.0 kB)
Comment
Answer by Addyarb · Aug 07, 2016 at 12:11 AM
In order to save your Player Prefs value, you need to first SET it. The PlayerPrefs value "Cost" is not linked to your public float "cost."
To set a PlayerPrefs value, use PlayerPrefs.SetInt();
For Instance:
PlayerPrefs.SetInt("cost",100);
Please read the documentation and if you have any questions, read this forum post.