Allows you to save and load games to PlayerPrefs without writing any scripts.
More...
|
void | Awake () |
|
void | OnUse () |
| Upon receiving an "OnUse" message, this method saves, loads, or does nothing, based on the value of functionOnUse. More...
|
|
void | SaveGame (int slot) |
| Saves the game under the PlayerPrefs key, adding the slot number to support multiple save game slots. More...
|
|
void | SaveGame () |
| Saves the game in default slot 0. More...
|
|
void | LoadGame (int slot) |
| Loads the game from the data saved under the PlayerPrefs key. More...
|
|
void | LoadGame () |
| Loads the game from default slot 0. More...
|
|
void | SaveGame (string slotString) |
| Saves the game using a string parameter for the slot number. More...
|
|
void | LoadGame (string slotString) |
| Loads the game using a string parameter for the slot number. More...
|
|
void | RestartGame () |
| Restarts the game. More...
|
|
void | Record () |
| Records the state of the game. More...
|
|
void | Apply () |
| Applies the recorded state of the game to the current scene. More...
|
|
Allows you to save and load games to PlayerPrefs without writing any scripts.
To use this component:
- Add this component to a game object.
- Set the playerPrefs key (i.e., saved game slot) where the game will be saved and loaded. To make multiple slots, you can add more GamerSaver components to change the playerPrefsKey field.
- To save a game, send the message "SaveGame" to this component (or call it from a script). For example, you can use the SendMessageOnConversation component to send the message.
- To load a game, send the message "LoadGame" to this component (or call it from a script).
- To restart the game, send the message "RestartGame" (or call it from a script).
- To record the state of the game without saving, for example when changing levels, send the "Record" message.
- To apply the saved state of the game, for example when returning to a level, send the "Apply" message.
- You can also configure this component to save or load when the player "uses" the game object. To do this:
- Set Function On Use to Save or Load. This tells the component whether to save or load when it receives an OnUse message.
- Send the message "OnUse" to this component or game object. For example, the sample Selector component sends OnUse when the player hits spacebar over the object.
- If you tick Apply Game State When Loading Levels, then this component will automatically apply the recorded game state as soon as the level is loaded. You're responsible for issuing the "Record" message before loading the level. You can use PersistentDataManager to do this.
- If the scene contains a LevelManager, it will load using the LevelManager instead of just applying the saved-game data.
◆ FunctionOnUse
Enumerator |
---|
None | |
Save | |
Load | |
Restart | |
◆ Apply()
void PixelCrushers.DialogueSystem.GameSaver.Apply |
( |
| ) |
|
Applies the recorded state of the game to the current scene.
◆ Awake()
void PixelCrushers.DialogueSystem.GameSaver.Awake |
( |
| ) |
|
◆ LoadGame() [1/3]
void PixelCrushers.DialogueSystem.GameSaver.LoadGame |
( |
| ) |
|
Loads the game from default slot 0.
◆ LoadGame() [2/3]
void PixelCrushers.DialogueSystem.GameSaver.LoadGame |
( |
int |
slot | ) |
|
Loads the game from the data saved under the PlayerPrefs key.
◆ LoadGame() [3/3]
void PixelCrushers.DialogueSystem.GameSaver.LoadGame |
( |
string |
slotString | ) |
|
Loads the game using a string parameter for the slot number.
- Parameters
-
slotString | Slot string to convert to an int. |
◆ OnUse()
void PixelCrushers.DialogueSystem.GameSaver.OnUse |
( |
| ) |
|
Upon receiving an "OnUse" message, this method saves, loads, or does nothing, based on the value of functionOnUse.
◆ Record()
void PixelCrushers.DialogueSystem.GameSaver.Record |
( |
| ) |
|
Records the state of the game.
◆ RestartGame()
void PixelCrushers.DialogueSystem.GameSaver.RestartGame |
( |
| ) |
|
◆ SaveGame() [1/3]
void PixelCrushers.DialogueSystem.GameSaver.SaveGame |
( |
| ) |
|
Saves the game in default slot 0.
◆ SaveGame() [2/3]
void PixelCrushers.DialogueSystem.GameSaver.SaveGame |
( |
int |
slot | ) |
|
Saves the game under the PlayerPrefs key, adding the slot number to support multiple save game slots.
- Parameters
-
◆ SaveGame() [3/3]
void PixelCrushers.DialogueSystem.GameSaver.SaveGame |
( |
string |
slotString | ) |
|
Saves the game using a string parameter for the slot number.
- Parameters
-
slotString | Slot string to convert to an int. |
◆ dontDestroyOnLoad
bool PixelCrushers.DialogueSystem.GameSaver.dontDestroyOnLoad = false |
If true
, this game object isn't destroyed when you load a new level.
◆ functionOnUse
The function (save or load) to perform when receiving the "OnUse" message.
◆ includeAllItemData
bool PixelCrushers.DialogueSystem.GameSaver.includeAllItemData = false |
If true
, saved-game data will include all item fields.
If false
, it will only include quests' State and Track fields.
◆ includeLocationData
bool PixelCrushers.DialogueSystem.GameSaver.includeLocationData = false |
If true
, saved-game data will include all location fields.
If false
, it will not include any location fields.
◆ includeSimStatus
bool PixelCrushers.DialogueSystem.GameSaver.includeSimStatus = false |
If true
, saved-game data will include the offered/spoken status of all dialogue entries.
◆ onLoadEnd
UnityEvent PixelCrushers.DialogueSystem.GameSaver.onLoadEnd = new UnityEvent() |
◆ onLoadStart
UnityEvent PixelCrushers.DialogueSystem.GameSaver.onLoadStart = new UnityEvent() |
◆ onSaveEnd
UnityEvent PixelCrushers.DialogueSystem.GameSaver.onSaveEnd = new UnityEvent() |
◆ onSaveStart
UnityEvent PixelCrushers.DialogueSystem.GameSaver.onSaveStart = new UnityEvent() |
◆ playerPrefsKey
string PixelCrushers.DialogueSystem.GameSaver.playerPrefsKey = "savedgame" |
The root of the PlayerPrefs key where the game will be saved and loaded.
◆ slot
int PixelCrushers.DialogueSystem.GameSaver.slot = 0 |
The default slot.
This number is appended to playerPrefsKey to make the complete PlayerPrefs key.
◆ startingLevel
string PixelCrushers.DialogueSystem.GameSaver.startingLevel = string.Empty |
The starting level to use when restarting the game.
The documentation for this class was generated from the following file:
- D:/Documents/Unity Projects/Dialogue System/Dev/Source/Assets/Dialogue System/Scripts/Supplemental/Save System/GameSaver.cs