// Copyright (c) Pixel Crushers. All rights reserved. using UnityEngine; namespace PixelCrushers { /// /// Provides inspector-selectable methods to control SaveSystem. /// [AddComponentMenu("")] // Use wrapper instead. public class SaveSystemMethods : MonoBehaviour { [Tooltip("Scene to load in LoadOrRestart method if no saved game exists yet.")] public string defaultStartingSceneName; /// /// Saves the current game in the specified slot. /// /// slot to save. public virtual void SaveSlot(int slotNumber) { SaveSystem.SaveToSlot(slotNumber); } /// /// Loads the game previously-saved in the specified slot. /// /// Slot to load. public virtual void LoadFromSlot(int slotNumber) { SaveSystem.LoadFromSlot(slotNumber); } /// /// Changes scenes. You can optionally specify a player spawnpoint by /// adding '@' and the spawnpoint GameObject name. /// /// Scene name followed by an optional at-sign and spawnpoint name. public virtual void LoadScene(string sceneNameAndSpawnpoint) { SaveSystem.LoadScene(sceneNameAndSpawnpoint); } /// /// Resets all saved game data. /// public virtual void ResetGameState() { SaveSystem.ResetGameState(); } /// /// Resets all saved game data and restarts the game at the specified scene. /// /// Scene to restart at. public virtual void RestartGame(string startingSceneName) { SaveSystem.RestartGame(startingSceneName); } /// /// Load the specified slot, or restart the game from the default /// starting scene if no save exists yet. /// /// Slot number to load. public virtual void LoadOrRestart(int slotNumber) { if (SaveSystem.HasSavedGameInSlot(slotNumber)) { SaveSystem.LoadFromSlot(slotNumber); } else { SaveSystem.RestartGame(defaultStartingSceneName); } } /// /// Deletes the saved game in the specified slot. /// public virtual void DeleteSavedGameInSlot(int slotNumber) { SaveSystem.DeleteSavedGameInSlot(slotNumber); } /// /// Records the current game state into the Save System. /// public virtual void RecordSavedGameData() { SaveSystem.RecordSavedGameData(); } /// /// Applies the most recently recorded game state. /// public virtual void ApplySavedGameData() { SaveSystem.ApplySavedGameData(); } /// /// Additively loads another scene. /// /// Scene to additively load. public virtual void LoadAdditiveScene(string sceneName) { SaveSystem.LoadAdditiveScene(sceneName); } /// /// Unloads a previously additively-loaded scene. /// /// Scene to unload public virtual void UnloadAdditiveScene(string sceneName) { SaveSystem.UnloadAdditiveScene(sceneName); } } }