public void LoadFile() { FileStream file; int[,] map; string destination = Application.persistentDataPath; string fileName = destination + levelName.text; if (File.Exists(fileName)) { file = File.OpenRead(fileName); } else { Debug.LogError("File not found"); return; } BinaryFormatter bf = new BinaryFormatter(); GameData data = (GameData)bf.Deserialize(file); file.Close(); map = data.map; mapInfo.SetMapDimensions(data.width, data.height); mapInfo.SetMap(map); string currentName = data.fileName; Debug.Log(data.fileName); Debug.Log(data.map.Length); }
public void LoadFile() { FileStream file; int[,] map; string fileName = _GM.GetCurrentLevel(); levelNameDisplay.text = Path.GetFileName(fileName); if (File.Exists(fileName)) { file = File.OpenRead(fileName); } else { Debug.LogError("File not found"); return; } BinaryFormatter bf = new BinaryFormatter(); GameData data = (GameData)bf.Deserialize(file); file.Close(); map = data.map; mapInfo.SetMapDimensions(data.width, data.height); mapInfo.SetMap(map); string currentName = data.fileName; Debug.Log(data.fileName); }