This is the main Save System class. More...
Public Member Functions | |
delegate void | SceneLoadedDelegate (string sceneName, int sceneIndex) |
void | OnLevelWasLoaded (int level) |
void | SaveGameToSlot (int slotNumber) |
Saves a game into a slot using the storage provider on the Save System GameObject. More... | |
void | LoadGameFromSlot (int slotNumber) |
Loads a game from a slot using the storage provider on the Save System GameObject. More... | |
void | LoadSceneAtSpawnpoint (string sceneNameAndSpawnpoint) |
Loads a scene, optionally positioning the player at a specified spawnpoint. More... | |
Static Public Member Functions | |
static string | GetCurrentSceneName () |
static int | GetCurrentSceneIndex () |
static bool | HasSavedGameInSlot (int slotNumber) |
Returns true if there is a saved game in the specified slot. More... | |
static void | DeleteSavedGameInSlot (int slotNumber) |
Deletes the saved game in the specified slot. More... | |
static void | SaveToSlot (int slotNumber) |
Saves the current game to a slot. More... | |
static void | LoadFromSlot (int slotNumber) |
Loads a game from a slot. More... | |
static void | RegisterSaver (Saver saver) |
static void | UnregisterSaver (Saver saver) |
static void | ClearSavedGameData () |
Clears the SaveSystem's internal saved game data cache. More... | |
static SavedGameData | RecordSavedGameData () |
Records the current scene's savers' data into the SaveSystem's internal saved game data cache. More... | |
static void | UpdateSaveData (Saver saver, string data) |
Updates the SaveSystem's internal saved game data cache with data for a specific saver. More... | |
static void | ApplySavedGameData (SavedGameData savedGameData) |
Applies the saved game data to the savers in the current scene. More... | |
static void | ApplySavedGameData () |
Applies the most recently recorded saved game data. More... | |
static void | BeforeSceneChange () |
If changing scenes manually, calls before changing scenes to inform components that listen for OnDestroy messages that they're being destroyed because of the scene change. More... | |
static void | LoadGame (SavedGameData savedGameData) |
Loads the scene recorded in the saved game data (if saveCurrentScene is true) and applies the saved game data to it. More... | |
static void | LoadScene (string sceneNameAndSpawnpoint) |
Loads a scene, optionally moving the player to a specified spawnpoint. More... | |
static void | RestartGame (string startingSceneName) |
Clears the SaveSystem's saved game data cache and loads a starting scene. More... | |
static string | Serialize (object data) |
Returns a serialized version of an object using whatever serializer is assigned to the SaveSystem (JSON by default). More... | |
static T | Deserialize< T > (string s, T data=default(T)) |
Deserializes a previously-serialized string representation of an object back into an object. More... | |
Public Attributes | |
const int | NoSceneIndex = -1 |
const string | LastSavedGameSlotPlayerPrefsKey = "savedgame_lastSlotNum" |
Stores an int indicating the slot number of the most recently saved game. More... | |
Properties | |
static bool | saveCurrentScene [get, set] |
When loading a game, load the scene that the game was saved in. More... | |
static int | framesToWaitBeforeApplyData [get, set] |
When loading a game/scene, wait this many frames before applying saved data to allow other scripts to initialize first. More... | |
static bool | debug [get, set] |
static SaveSystem | instance [get] |
static SceneTransitionManager | sceneTransitionManager [get] |
static SavedGameData | currentSavedGameData [get] |
The saved game data recorded by the last call to SaveToSlot, LoadScene, or RecordSavedGameData. More... | |
static GameObject | playerSpawnpoint [get, set] |
Where the player should spawn in the current scene. More... | |
static int | currentSceneIndex [get] |
Build index of the current scene. More... | |
Events | |
static SceneLoadedDelegate | sceneLoaded = delegate { } |
Invoked after a scene has been loaded. More... | |
static System.Action | saveStarted = delegate { } |
Invoked when starting to save a game. More... | |
static System.Action | saveEnded = delegate { } |
Invoked when finished saving a game. More... | |
static System.Action | loadStarted = delegate { } |
Invoked when starting to load a game. More... | |
static System.Action | loadEnded = delegate { } |
Invoked when finished loading a game. More... | |
This is the main Save System class.
It runs as a singleton MonoBehaviour and provides static methods to save and load games.
|
static |
Applies the saved game data to the savers in the current scene.
savedGameData | Saved game data. |
|
static |
Applies the most recently recorded saved game data.
|
static |
If changing scenes manually, calls before changing scenes to inform components that listen for OnDestroy messages that they're being destroyed because of the scene change.
|
static |
Clears the SaveSystem's internal saved game data cache.
|
static |
Deletes the saved game in the specified slot.
|
static |
Deserializes a previously-serialized string representation of an object back into an object.
Uses whatever serializer is assigned to the SaveSystem (JSON by default).
T | The type of the object. |
s | The object's serialized data. |
data | Optional preallocated object to serialize data into. |
|
static |
|
static |
|
static |
Returns true if there is a saved game in the specified slot.
|
static |
Loads a game from a slot.
|
static |
Loads the scene recorded in the saved game data (if saveCurrentScene is true) and applies the saved game data to it.
savedGameData |
void PixelCrushers.SaveSystem.LoadGameFromSlot | ( | int | slotNumber | ) |
Loads a game from a slot using the storage provider on the Save System GameObject.
slotNumber |
|
static |
Loads a scene, optionally moving the player to a specified spawnpoint.
sceneNameAndSpawnpoint | Scene name, followed by an optional spawnpoint separated by '@'. |
void PixelCrushers.SaveSystem.LoadSceneAtSpawnpoint | ( | string | sceneNameAndSpawnpoint | ) |
Loads a scene, optionally positioning the player at a specified spawnpoint.
sceneNameAndSpawnpoint | A string containing the name of the scene to load, optionally followed by "@spawnpoint" where "spawnpoint" is the name of a GameObject in that scene. The player will be spawned at that GameObject's position. |
void PixelCrushers.SaveSystem.OnLevelWasLoaded | ( | int | level | ) |
|
static |
Records the current scene's savers' data into the SaveSystem's internal saved game data cache.
|
static |
|
static |
Clears the SaveSystem's saved game data cache and loads a starting scene.
startingSceneName |
void PixelCrushers.SaveSystem.SaveGameToSlot | ( | int | slotNumber | ) |
Saves a game into a slot using the storage provider on the Save System GameObject.
slotNumber | Slot in which to store saved game data. |
|
static |
Saves the current game to a slot.
delegate void PixelCrushers.SaveSystem.SceneLoadedDelegate | ( | string | sceneName, |
int | sceneIndex | ||
) |
|
static |
Returns a serialized version of an object using whatever serializer is assigned to the SaveSystem (JSON by default).
|
static |
|
static |
Updates the SaveSystem's internal saved game data cache with data for a specific saver.
saver | |
data |
const string PixelCrushers.SaveSystem.LastSavedGameSlotPlayerPrefsKey = "savedgame_lastSlotNum" |
Stores an int indicating the slot number of the most recently saved game.
const int PixelCrushers.SaveSystem.NoSceneIndex = -1 |
|
staticget |
The saved game data recorded by the last call to SaveToSlot, LoadScene, or RecordSavedGameData.
|
staticget |
Build index of the current scene.
|
staticgetset |
|
staticgetset |
When loading a game/scene, wait this many frames before applying saved data to allow other scripts to initialize first.
|
staticget |
|
staticgetset |
Where the player should spawn in the current scene.
|
staticgetset |
When loading a game, load the scene that the game was saved in.
|
staticget |
|
static |
Invoked when finished loading a game.
|
static |
Invoked when starting to load a game.
If assigned, waits one frame before starting the load to allow UIs to update.
|
static |
Invoked when finished saving a game.
|
static |
Invoked when starting to save a game.
If assigned, waits one frame before starting the save to allow UIs to update.
|
static |
Invoked after a scene has been loaded.