I have used below code for saving the multiple names using the array. But i have the issue in this. when i save the second name in array the first name also change. I dont know how to solve this, please help me to do this.
Please provide your full code. My guess would be that JOKE+no[0] and JOKE+no[1] produce the same key which would lead to JOKE+no[1] overrwriting JOKE+no[0].
public int[] no;
int i;
// Use this for initialization
void Start () {
i=2;
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
PlayerPrefs.SetInt("No", no[0]);
PlayerPrefs.SetString("JOKE"+PlayerPrefs.GetInt("No"), "one");
PlayerPrefs.SetInt("No", no[1]);
PlayerPrefs.SetString("JOKE"+PlayerPrefs.GetInt("No"), "two");
}
}
Ok so this code is a bit different but this is what happends: you save int no[0] with key “No”, two lines later you overwrite that value with int no[1].
Its important to understand that if you want to save multiple values you need multiple and unique keys. (also if no[0] and no[1] are the same value, this example would fail too)