PixelCrushers.Saver Class Referenceabstract

Abstract base class for a "saver", which is a component that contributes to saved game data. More...

Inheritance diagram for PixelCrushers.Saver:
Collaboration diagram for PixelCrushers.Saver:

Public Member Functions

virtual void Awake ()
 
virtual void Start ()
 
virtual void Reset ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
virtual void OnDestroy ()
 
string RecordData ()
 This method should return a string that represents the data you want to save.
 
void ApplyData (string s)
 This method should process the string representation of saved data and apply it to the current state of the game.
 
virtual void ApplyDataImmediate ()
 If the Saver needs to pull data from the Save System immediately after loading a scene, instead of waiting for ApplyData to be called at it its normal time, it can implement this method.
 
virtual void OnBeforeSceneChange ()
 The Save System will call this method before scene changes.
 
virtual void OnRestartGame ()
 The Save System will call this method when restarting the game.
 

Protected Attributes

string m_runtimeKey = null
 

Properties

bool appendSaverTypeToKey [get, set]
 Append the name of this saver type to the key.
 
virtual string key [get, set]
 Save data under this key.
 
string _internalKeyValue [get, set]
 Accesses the internal key value.
 
virtual bool saveAcrossSceneChanges [get, set]
 Save when changing scenes to be able to restore saved state when returning to scene.
 
virtual bool restoreStateOnStart [get, set]
 

Detailed Description

Abstract base class for a "saver", which is a component that contributes to saved game data.

Member Function Documentation

◆ ApplyData()

void PixelCrushers.Saver.ApplyData ( string  s)
abstract

This method should process the string representation of saved data and apply it to the current state of the game.

You can use SaveSystem.Deserialize() to deserialize the string to an object that specifies the state to apply to the game.

◆ ApplyDataImmediate()

virtual void PixelCrushers.Saver.ApplyDataImmediate ( )
inlinevirtual

If the Saver needs to pull data from the Save System immediately after loading a scene, instead of waiting for ApplyData to be called at it its normal time, it can implement this method.

For efficiency, the Save System will not look up the Saver's data; your method must look it up manually by calling SaveSystem.savedGameData.GetData(key).

Reimplemented in PixelCrushers.DialogueSystem.ARPGSupport.DSSaveLoad, and PixelCrushers.DialogueSystem.DialogueSystemSaver.

◆ Awake()

◆ OnBeforeSceneChange()

virtual void PixelCrushers.Saver.OnBeforeSceneChange ( )
inlinevirtual

The Save System will call this method before scene changes.

If your saver listens for OnDisable or OnDestroy messages (see DestructibleSaver for example), it can use this method to ignore the next OnDisable or OnDestroy message since they will be called because the entire scene is being unloaded.

Reimplemented in PixelCrushers.DialogueSystem.InkSupport.InkSaver, PixelCrushers.DestructibleSaver, PixelCrushers.SpawnedObject, and PixelCrushers.DialogueSystem.DialogueSystemSaver.

◆ OnDestroy()

virtual void PixelCrushers.Saver.OnDestroy ( )
inlinevirtual

◆ OnDisable()

virtual void PixelCrushers.Saver.OnDisable ( )
inlinevirtual

◆ OnEnable()

virtual void PixelCrushers.Saver.OnEnable ( )
inlinevirtual

◆ OnRestartGame()

virtual void PixelCrushers.Saver.OnRestartGame ( )
inlinevirtual

The Save System will call this method when restarting the game.

Your saver can reset data to a fresh state if necessary.

Reimplemented in PixelCrushers.DialogueSystem.InkSupport.InkSaver, and PixelCrushers.DialogueSystem.DialogueSystemSaver.

◆ RecordData()

string PixelCrushers.Saver.RecordData ( )
abstract

This method should return a string that represents the data you want to save.

You can use SaveSystem.Serialize() to serialize a serializable object to a string. This will use the serializer component on the Save System GameObject, which defaults to JSON serialization.

◆ Reset()

◆ Start()

virtual void PixelCrushers.Saver.Start ( )
inlinevirtual

Member Data Documentation

◆ m_runtimeKey

string PixelCrushers.Saver.m_runtimeKey = null
protected

Property Documentation

◆ _internalKeyValue

string PixelCrushers.Saver._internalKeyValue
getset

Accesses the internal key value.

Normally leave this untouched and access the key property instead.

◆ appendSaverTypeToKey

bool PixelCrushers.Saver.appendSaverTypeToKey
getset

Append the name of this saver type to the key.

◆ key

virtual string PixelCrushers.Saver.key
getset

Save data under this key.

If blank, use GameObject name.

◆ restoreStateOnStart

virtual bool PixelCrushers.Saver.restoreStateOnStart
getset

◆ saveAcrossSceneChanges

virtual bool PixelCrushers.Saver.saveAcrossSceneChanges
getset

Save when changing scenes to be able to restore saved state when returning to scene.


The documentation for this class was generated from the following file: