I have been in unity for about 2 years and im encountring this problem.
Which the player prefs key just wont delete.
if anyone can point me out what im missing it would be awesome.
while (PlayerPrefs.GetString("codes." + counter) != "")
{
if (PlayerPrefs.GetString("codes." + counter) == c.nameText)
{
string nameS = PlayerPrefs.GetString("codes." + counter);
PlayerPrefs.DeleteKey("codes." + counter);
PlayerPrefs.DeleteKey(nameS + ".name");
PlayerPrefs.DeleteKey(nameS + ".quantity");
PlayerPrefs.DeleteKey(nameS + ".prefered_quantity");
for (int i = 0; i < c.codes.Count; i++)
{
PlayerPrefs.DeleteKey(c.nameText + ".codes." + i);
}
PlayerPrefs.Save();
}
counter++;
}
List codes = new List();
foreach (string s in c.codes)
{
codes.Add(s);
}
Cell c1 = AddNew(name, "213", quantity, prefered);
foreach (string code in codes)
{
c1.AddCode(code);
}
Save();
Save function :
public void Save()
{
int counter = 0;
foreach (Transform t in table)
{
Cell c = t.GetComponent();
PlayerPrefs.SetString("codes." + counter, c.nameText);
PlayerPrefs.SetString(c.nameText + ".name", c.nameText);
PlayerPrefs.SetInt(c.nameText + ".quantity", c.quantityI);
PlayerPrefs.SetInt(c.nameText + ".prefered_quantity", c.preferedQuan);
for (int i = 0; i < c.codes.Count; i++)
{
PlayerPrefs.SetString(c.nameText + ".codes." + i, c.codes[i]);
}
counter++;
}
PlayerPrefs.Save();
}
im probably an idiot who cant see the problem |
↧