- Home /
List Saving Problem
What I want to do is a ball shop. In this store you will select a random ball from the list of pools by clicking on the Buy button and you will be able to select from the list of pools (analyst ye) to remove this sprite from the pool for the next time. Think of it as a preview of a gameObject (2) in the form of a sprite with the right button and the left button in order to make the main sprites in turn. then the okey button will make the sprite selected in the main sprite preview (the main list) in the main ball sprite (in another scene). All of these lists will be saved. Everything works fine when I play over unity on the computer in the code, list are not save when I create an apk and throw it on the phone.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class spriteselector : MonoBehaviour {
public magazaana magazaanaliste;
public static int index;
public SpriteRenderer gmo ;
public static int randomtop;
public static int a;
public GameObject panel;
public Image panelresim;
public Rigidbody2D makine;
public static int para;
public GameObject panel2;
public int fiyat = 2;
void Start(){
a = PlayerPrefs.GetInt ("seciliindex",index );
index = a;
panel.SetActive (false);
panel2.SetActive (false);
gmo.sprite = magazaanaliste.AnaListe[a];
para = PlayerPrefs.GetInt ("b");
}
public void Right () {
if (index < magazaanaliste.AnaListe.Count- 1) {
index++;
gmo.sprite = magazaanaliste.AnaListe [index];
ball.sprite = magazaanaliste.AnaListe [index];
}
}
public void Left(){
if (index > 0) {
index--;
gmo.sprite = magazaanaliste.AnaListe [index];
ball.sprite = magazaanaliste.AnaListe [index];
}
}
public void saveandback(){
SceneManager.LoadScene (0);
PlayerPrefs.SetInt ("seciliindex",index);
PlayerPrefs.Save ();
}
public void rastgele(){
if (para >= fiyat) {
makine.AddTorque (8000);
StartCoroutine ("donmesonrasi");
para = para - fiyat;
PlayerPrefs.SetInt ("b", para);
}
if (para < fiyat) {
StartCoroutine ("yetersizpara");
}
}
IEnumerator yetersizpara(){
panel2.SetActive (true);
yield return new WaitForSecondsRealtime(1f);
panel2.SetActive (false);
}
IEnumerator donmesonrasi(){
yield return new WaitForSecondsRealtime (4f);
randomtop = Random.Range (0, magazaanaliste.Havuz.Count -1);
magazaanaliste.AnaListe.Add (magazaanaliste.Havuz [randomtop]);
panel.SetActive (true);
panelresim.sprite = magazaanaliste.Havuz[randomtop];
magazaanaliste.Havuz.Remove (magazaanaliste.Havuz [randomtop]);
yield return new WaitForSecondsRealtime (2f);
panel.SetActive (false);
}
}
this code in prefab folder
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class magazaana : MonoBehaviour {
public List <Sprite> AnaListe = new List <Sprite>();
public List <Sprite> Havuz = new List <Sprite>();
}
Your answer

Follow this Question
Related Questions
A node in a childnode? 1 Answer
Increment based 'if' conditions not being met for the later conditions. Any solutions ? 0 Answers
BinaryFormatter - saving and loading a list containing sprites. 0 Answers
Argument out of range exception 1 Answer
hay i am new in saving and loading date in binary formate I wana to save and load list of data 1 Answer