public bool Load(GameState gameStateToLoad) { string filePath = Path.Combine(Application.persistentDataPath, SAVE_FILE_NAME); if (File.Exists(filePath)) { XElement document = XElement.Parse(File.ReadAllText(filePath)); XElement gameStateElement = document.Element("GameState"); Debug.Log("Loading game state..."); try { gameStateToLoad.Parse(gameStateElement); return(true); } catch (FormatException) { Debug.LogError("Tried to load a map with a wrong format."); } catch (ArgumentNullException) { Debug.LogError("Tried to load a map with a wrong format."); } } return(false); }