Inventory Engine v4.2
Loading...
Searching...
No Matches
MoreMountains.Tools.MMPersistenceManager Class Reference

Add this component to a scene and it'll let you save and load the state of objects that implement the IMMPersistent interface You can create your own classes that implement this interface, or use the MMPersistent class that comes with this package It will save their transform data (position, rotation, scale) and their active state Triggering save and load is done via events, and the manager also emits events every time data is loaded or saved. More...

Inherits MoreMountains.Tools.MMPersistentSingleton< T >, and MoreMountains.Tools.MMEventListener< T >.

Public Member Functions

virtual void SaveToMemory ()
 Saves data from objects that need saving to memory.
virtual void LoadFromMemory ()
 Loads data from memory and applies it to all objects that need it.
virtual void SaveFromMemoryToFile ()
 Saves data from memory to a file.
virtual void LoadFromFileToMemory ()
 Loads data from file and stores it in memory.
virtual void Save ()
 On Save, we save to memory and to file if needed.
virtual void Load ()
 On Load, we load from memory and from file if needed.
virtual void DeletePersistencyMemoryForScene (string sceneName)
 Deletes all persistence data for the specified scene.
virtual void ResetPersistence ()
 Deletes persistence data from memory and on file for this persistence manager.
virtual void DeletePersistenceMemory ()
 Deletes all persistence data stored in this persistence manager's memory.
virtual void DeletePersistenceFile ()
 Deletes the save file for this persistence manager.
virtual void OnMMEvent (MMGameEvent gameEvent)
 When we get a MMEvent, we filter on its name and invoke the appropriate methods if needed.
Public Member Functions inherited from MoreMountains.Tools.MMEventListener< T >
void OnMMEvent (T eventType)

Public Attributes

string PersistenceID = "MMPersistency"
 A persistence ID used to identify the data associated to this manager.
bool ListenForSaveEvents = true
 whether or not this manager should listen for save events. If you set this to false, you'll have to call SaveToMemory or SaveFromMemoryToFile manually
bool ListenForLoadEvents = true
 whether or not this manager should listen for load events. If you set this to false, you'll have to call LoadFromMemory or LoadFromFileToMemory manually
bool ListenForSaveToMemoryEvents = true
 whether or not this manager should listen for save to memory events. If you set this to false, you'll have to call SaveToMemory manually
bool ListenForLoadFromMemoryEvents = true
 whether or not this manager should listen for load from memory events. If you set this to false, you'll have to call LoadFromMemory manually
bool ListenForSaveToFileEvents = true
 whether or not this manager should listen for save to file events. If you set this to false, you'll have to call SaveFromMemoryToFile manually
bool ListenForLoadFromFileEvents = true
 whether or not this manager should listen for load from file events. If you set this to false, you'll have to call LoadFromFileToMemory manually
bool SaveToFileOnSaveEvents = true
 whether or not this manager should save data to file on save events
bool LoadFromFileOnLoadEvents = true
 whether or not this manager should load data from file on load events
bool SaveToMemoryButton
 the debug buttons below are only meant to be used at runtime
bool LoadFromMemoryButton
bool SaveToFileButton
bool LoadFromFileButton
bool DeletePersistenceFileButton
DictionaryStringSceneData SceneDatas
Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< T >
bool AutomaticallyUnparentOnAwake = true
 if this is true, this singleton will auto detach if it finds itself parented on awake

Static Public Attributes

static string _resourceItemPath = "Persistence/"
static string _saveFolderName = "MMTools/"
static string _saveFileExtension = ".persistence"

Protected Member Functions

override void Awake ()
 On Awake we initialize our dictionary.
virtual IMMPersistent[] FindAllPersistentObjects ()
 Finds all objects in the scene that implement IMMPersistent and may need saving.
virtual void ComputeCurrentSceneName ()
 Grabs the current scene's name and stores it.
virtual string DetermineSaveName ()
 Determines the name of the file to write to store persistence data.
virtual void OnEnable ()
 On enable, we start listening for MMGameEvents.
virtual void OnDisable ()
 On enable, we stop listening for MMGameEvents.
Protected Member Functions inherited from MoreMountains.Tools.MMPersistentSingleton< T >
virtual void InitializeSingleton ()
 Initializes the singleton.

Static Protected Member Functions

static void InitializeStatics ()
 Statics initialization to support enter play modes.

Protected Attributes

string _currentSceneName
Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< T >
bool _enabled

Additional Inherited Members

Static Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< T >
static T _instance
Properties inherited from MoreMountains.Tools.MMPersistentSingleton< T >
static bool HasInstance [get]
static T Current [get]
static T Instance [get]
 Singleton design pattern.

Detailed Description

Add this component to a scene and it'll let you save and load the state of objects that implement the IMMPersistent interface You can create your own classes that implement this interface, or use the MMPersistent class that comes with this package It will save their transform data (position, rotation, scale) and their active state Triggering save and load is done via events, and the manager also emits events every time data is loaded or saved.

Member Function Documentation

◆ Awake()

override void MoreMountains.Tools.MMPersistenceManager.Awake ( )
protectedvirtual

On Awake we initialize our dictionary.

Reimplemented from MoreMountains.Tools.MMPersistentSingleton< T >.

◆ ComputeCurrentSceneName()

virtual void MoreMountains.Tools.MMPersistenceManager.ComputeCurrentSceneName ( )
protectedvirtual

Grabs the current scene's name and stores it.

◆ DeletePersistenceFile()

virtual void MoreMountains.Tools.MMPersistenceManager.DeletePersistenceFile ( )
virtual

Deletes the save file for this persistence manager.

◆ DeletePersistenceMemory()

virtual void MoreMountains.Tools.MMPersistenceManager.DeletePersistenceMemory ( )
virtual

Deletes all persistence data stored in this persistence manager's memory.

◆ DeletePersistencyMemoryForScene()

virtual void MoreMountains.Tools.MMPersistenceManager.DeletePersistencyMemoryForScene ( string sceneName)
virtual

Deletes all persistence data for the specified scene.

Parameters
sceneName

◆ DetermineSaveName()

virtual string MoreMountains.Tools.MMPersistenceManager.DetermineSaveName ( )
protectedvirtual

Determines the name of the file to write to store persistence data.

Returns

◆ FindAllPersistentObjects()

virtual IMMPersistent[] MoreMountains.Tools.MMPersistenceManager.FindAllPersistentObjects ( )
protectedvirtual

Finds all objects in the scene that implement IMMPersistent and may need saving.

Returns

◆ InitializeStatics()

void MoreMountains.Tools.MMPersistenceManager.InitializeStatics ( )
staticprotected

Statics initialization to support enter play modes.

◆ Load()

virtual void MoreMountains.Tools.MMPersistenceManager.Load ( )
virtual

On Load, we load from memory and from file if needed.

◆ LoadFromFileToMemory()

virtual void MoreMountains.Tools.MMPersistenceManager.LoadFromFileToMemory ( )
virtual

Loads data from file and stores it in memory.

◆ LoadFromMemory()

virtual void MoreMountains.Tools.MMPersistenceManager.LoadFromMemory ( )
virtual

Loads data from memory and applies it to all objects that need it.

◆ OnDisable()

virtual void MoreMountains.Tools.MMPersistenceManager.OnDisable ( )
protectedvirtual

On enable, we stop listening for MMGameEvents.

◆ OnEnable()

virtual void MoreMountains.Tools.MMPersistenceManager.OnEnable ( )
protectedvirtual

On enable, we start listening for MMGameEvents.

◆ OnMMEvent()

virtual void MoreMountains.Tools.MMPersistenceManager.OnMMEvent ( MMGameEvent gameEvent)
virtual

When we get a MMEvent, we filter on its name and invoke the appropriate methods if needed.

Parameters
gameEvent

◆ ResetPersistence()

virtual void MoreMountains.Tools.MMPersistenceManager.ResetPersistence ( )
virtual

Deletes persistence data from memory and on file for this persistence manager.

◆ Save()

virtual void MoreMountains.Tools.MMPersistenceManager.Save ( )
virtual

On Save, we save to memory and to file if needed.

◆ SaveFromMemoryToFile()

virtual void MoreMountains.Tools.MMPersistenceManager.SaveFromMemoryToFile ( )
virtual

Saves data from memory to a file.

◆ SaveToMemory()

virtual void MoreMountains.Tools.MMPersistenceManager.SaveToMemory ( )
virtual

Saves data from objects that need saving to memory.

Member Data Documentation

◆ _currentSceneName

string MoreMountains.Tools.MMPersistenceManager._currentSceneName
protected

◆ _resourceItemPath

string MoreMountains.Tools.MMPersistenceManager._resourceItemPath = "Persistence/"
static

◆ _saveFileExtension

string MoreMountains.Tools.MMPersistenceManager._saveFileExtension = ".persistence"
static

◆ _saveFolderName

string MoreMountains.Tools.MMPersistenceManager._saveFolderName = "MMTools/"
static

◆ DeletePersistenceFileButton

bool MoreMountains.Tools.MMPersistenceManager.DeletePersistenceFileButton

◆ ListenForLoadEvents

bool MoreMountains.Tools.MMPersistenceManager.ListenForLoadEvents = true

whether or not this manager should listen for load events. If you set this to false, you'll have to call LoadFromMemory or LoadFromFileToMemory manually

◆ ListenForLoadFromFileEvents

bool MoreMountains.Tools.MMPersistenceManager.ListenForLoadFromFileEvents = true

whether or not this manager should listen for load from file events. If you set this to false, you'll have to call LoadFromFileToMemory manually

◆ ListenForLoadFromMemoryEvents

bool MoreMountains.Tools.MMPersistenceManager.ListenForLoadFromMemoryEvents = true

whether or not this manager should listen for load from memory events. If you set this to false, you'll have to call LoadFromMemory manually

◆ ListenForSaveEvents

bool MoreMountains.Tools.MMPersistenceManager.ListenForSaveEvents = true

whether or not this manager should listen for save events. If you set this to false, you'll have to call SaveToMemory or SaveFromMemoryToFile manually

◆ ListenForSaveToFileEvents

bool MoreMountains.Tools.MMPersistenceManager.ListenForSaveToFileEvents = true

whether or not this manager should listen for save to file events. If you set this to false, you'll have to call SaveFromMemoryToFile manually

◆ ListenForSaveToMemoryEvents

bool MoreMountains.Tools.MMPersistenceManager.ListenForSaveToMemoryEvents = true

whether or not this manager should listen for save to memory events. If you set this to false, you'll have to call SaveToMemory manually

◆ LoadFromFileButton

bool MoreMountains.Tools.MMPersistenceManager.LoadFromFileButton

◆ LoadFromFileOnLoadEvents

bool MoreMountains.Tools.MMPersistenceManager.LoadFromFileOnLoadEvents = true

whether or not this manager should load data from file on load events

◆ LoadFromMemoryButton

bool MoreMountains.Tools.MMPersistenceManager.LoadFromMemoryButton

◆ PersistenceID

string MoreMountains.Tools.MMPersistenceManager.PersistenceID = "MMPersistency"

A persistence ID used to identify the data associated to this manager.

Usually you'll want to leave this to its default value.

◆ SaveToFileButton

bool MoreMountains.Tools.MMPersistenceManager.SaveToFileButton

◆ SaveToFileOnSaveEvents

bool MoreMountains.Tools.MMPersistenceManager.SaveToFileOnSaveEvents = true

whether or not this manager should save data to file on save events

◆ SaveToMemoryButton

bool MoreMountains.Tools.MMPersistenceManager.SaveToMemoryButton

the debug buttons below are only meant to be used at runtime

◆ SceneDatas

DictionaryStringSceneData MoreMountains.Tools.MMPersistenceManager.SceneDatas

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