I have a level loading script that draws a level from an array representation loaded from file. This works fine in unity editor but when I build for ios those objects dynamically drawn do not load.
Here is the code that does the drawing:
void DrawNewLevel(int level) {
LevelEditor.Level lvl = new LevelEditor.Level (1, level);
for (int x = 0; x < 260; x++) {
for (int y = 0; y < 23; y++) {
GameObject gameObject;
if (lvl.LevelContents[x, y].BlockType != LevelEditor.BlockType.Empty) {
if (lvl.LevelContents[x, y].BlockType == LevelEditor.BlockType.Floor) {
gameObject = Instantiate(Floor);
gameObject.transform.position = new Vector3(x, 23-y, 0);
} else if (lvl.LevelContents[x, y].BlockType == LevelEditor.BlockType.FloorBad) {
gameObject = Instantiate(FloorBad);
gameObject.transform.position = new Vector3(x, 23-y, 0);
} else if (lvl.LevelContents[x, y].BlockType == LevelEditor.BlockType.SmartRocketLauncher) {
gameObject = Instantiate(SmartRocketLauncher);
gameObject.transform.position = new Vector3(x, 23-y, 1);
}
}
}
}
}
Here is the code that loads the file:
string fileName = @"Scripts/Levels/" + level.ToString() + ".lvl";
string filePath = Path.Combine(Application.dataPath, fileName);
↧