- Home /
Question by
olgackrdg · May 11 at 01:40 AM ·
c#unity 5playerprefs
PlayerPrefs doesn't work right. Whatever the integer variable I put as an input, GetInt always returns 0.
void Start()
{
for (int i = 1; i <= 17; i++)
{
if (PlayerPrefs.HasKey(mark[i - 1]))
{
borclar[i - 1] = PlayerPrefs.GetInt(mark[i - 1]);
d_bilgiler[i - 1].text = "Daire -" + (i) + " Borcu =" + borclar[i - 1];
Debug.Log("veri işlendi" + borclar[i - 1]);
}
}
}
public void kaydet_buton()
{
for(int i = 1; i <= 17; i++)
{
button_name = "Button " + i;
input_name = "d" + i + "input";
text_name = "d" + i;
if (EventSystem.current.currentSelectedGameObject.name == button_name)
{
GameObject.Find(text_name).GetComponent<Text>().text ="Daire -" + i + " =" + GameObject.Find(input_name).GetComponent<InputField>().text;
borclar[i - 1] = int.Parse(GameObject.Find(input_name).GetComponent<InputField>().text);
mark[i - 1] = "" + i;
PlayerPrefs.SetInt(mark[i-1], borclar[i-1]);
PlayerPrefs.Save();
Debug.Log("data saved" + PlayerPrefs.GetInt(mark[i - 1]));
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Android Build not deleting PlayerPrefs 1 Answer
How to load android app when the button clicked in unity scene? 4 Answers