// Save a SaveFile at path and reshape/rename linked button private void CreateUserSaveFile() { var path = Application.persistentDataPath; var newSave = new SaveFileTemplate(inputSaveName.text, (int)GameManager.Instance.difficulty, saveButtonId); XMLFilHelper.CreateXmlFile(path + saveButtonId, newSave); UIUtilities.ChangeButtonVisual(saveButton, saveButtonColors); string buttonText = "Name : " + newSave.Name + "\n" + GetDifficultyString(); UIUtilities.RenameButton(saveButton, buttonText, TextAnchor.MiddleCenter, 18); }
// Look for existing save file in the Save Files document and change save buttons accordingly public void CheckForSaveFile() { var path = Application.persistentDataPath; for (int i = 1; i < 4; i++) { if (File.Exists(path + i)) { var button = MainMenuManager.Instance.saveMenu.saveButtons[i - 1]; var currentSaveFile = XMLFilHelper.LoadFile(path + i, typeof(SaveFileTemplate)) as SaveFileTemplate; string buttonText = "Name : " + currentSaveFile.Name + "\n" + GetDifficultyString(); UIUtilities.ChangeButtonVisual(button, saveButtonColors); UIUtilities.RenameButton(button, buttonText, TextAnchor.MiddleCenter, 18); } } }
// Delete a Save File public void DeleteUserSaveFile() { var path = Application.persistentDataPath + saveButtonId; XMLFilHelper.DeleteFile(path); }