As a preface, I have already looked through all other mentionings of people with this problem, but none of their solutions seem to work.
In my project, I’m attempting to load levels stored as text files with the .map extension inside the StreamingAssets folder. On PC, this works flawlessly, no problems there, but no matter what I try I cannot get it to function on Android.
What I’m currently using (while faulty) to load files is:
public void LoadScene(){
if(Application.isMobilePlatform){
using(StreamReader sr = new StreamReader(Application.persistentDataPath + "/StreamingAssets/Levels/" + levelName)){
gridX = int.Parse(sr.ReadLine ());
gridY = int.Parse(sr.ReadLine ());
level = new int[gridX, gridY];
string[] yList = new string[gridY];
for(int i = 0; i < yList.Length; i++){
yList *= sr.ReadLine();*
-
}*
-
for(int y = 0; y < gridY; y++) { *
-
for(int x = 0; x < gridX; x++){*
-
string[] xList = yList[y].Split(',');*
-
level[x, y] = int.Parse (xList[x]);*
-
//print (level[x, y]);*
-
}*
-
}*
-
}*
-
}else{*
-
if(Application.dataPath + "/StreamingAssets/Levels/" + levelName != null){*
-
using(StreamReader sr = new StreamReader(Application.dataPath + "/StreamingAssets/Levels/" + levelName)){*
-
gridX = int.Parse(sr.ReadLine());*
-
gridY = int.Parse(sr.ReadLine());*
-
level = new int[gridX, gridY];*
-
string[] yList = new string[gridY];*
-
for(int i = 0; i < yList.Length; i++) {*
_ yList = sr.ReadLine();_
* }*
* for(int y = 0; y<gridY; y++) { *
* for (int x = 0; x<gridX; x++) {*
* string[] xList = yList [y].Split(‘,’);*
* level[x, y] = int.Parse(xList[x]);*
* //print (level[x, y]);*
* }*
* }*
* }*
* }else{*
* print (“Level not found”);*
* }*
* }*
The levels are stored in (on PC) streamingassets/Levels/