Question by
CDAXRC · Apr 29, 2018 at 12:20 PM ·
playerprefssave
My Player.Prefs can't save or load float?
public class gameController : MonoBehaviour
{
public float lifes = 10;
// Use this for initialization
void Start()
{
float lifes = PlayerPrefs.GetFloat("lifes");
}
void lifecount()
{
PlayerPrefs.SetFloat("lifes", lifes);
lifes -= 0.5f;
PlayerPrefs.Save();
}
}
Hi, what's wrong with this? When I invoke void lifecount code correctly reduce lifes value but this can't save new value.
Comment
the problem is here
PlayerPrefs.SetFloat("lifes", lifes);
lifes -= 0.5f;
you should change it to
lifes -= 0.5f;
PlayerPrefs.SetFloat("lifes", lifes);
Your answer
Follow this Question
Related Questions
Save/load not work on mobile phone 1 Answer
Playerprefs, i dont know how to use 0 Answers
Save and load component values 0 Answers
PlayerPrefs Autosave [SOLVED] 2 Answers
Player Party Save 0 Answers