I might have a little bit trouble I am assuming just a simple mistake but yet I can not find the the solution well even worse the mistake, now what I am trying to do is to load all file in my folder by looping it until the max number reached
IEnumerator loadData()
{
Debug.Log (loadNum);
if (File.Exists (Application.persistentDataPath + "/data[" + loadNum + "].octa")) {
BinaryFormatter loadData = new BinaryFormatter ();
FileStream dataFile = File.Open (Application.persistentDataPath + "/data[" + loadNum + "].octa", FileMode.Open);
playerData pData = (playerData)loadData.Deserialize (dataFile);
dataFile.Close ();
name_O = pData.name;
job_O = pData.job;
difficulty_O = pData.difficulty;
rawAPD = name_O + "/" + job_O.ToString() + "/" + difficulty_O.ToString();
APD = new string[loadNum += 1];
for (var i = 0; i <= loadNum && i < loadNum; i++)
{
if (APD [i] == null)
{
APD [i] = rawAPD;
}
break;
}
yield return new WaitForSeconds (1);
if (loadNum != numOfSaveFile_O)
{
Debug.Log ("meh");
loadNum += 1;
reLoop ();
}
}
else
{
if (loadNum != numOfSaveFile_O)
{
loadNum += 1;
reLoop ();
}
}
}
void reLoop()
{
StartCoroutine (loadData ());
}
now everything work great as expected after the yield thing
the number jumps from 0 to 2
the scenario here is I do have data[0]
and data[1]
file in my persistent data path