TopDown Engine  v3.6
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...

Inheritance diagram for MoreMountains.Tools.MMPersistenceManager:
MoreMountains.Tools.MMPersistentSingleton< MMPersistenceManager > MoreMountains.Tools.MMEventListener< MMGameEvent >

Public Member Functions

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

Public Attributes

string PersistenceID = "MMPersistency"
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
bool SaveToFileOnSaveEvents = true
 whether or not this manager should save data to file on save events More...
 
bool LoadFromFileOnLoadEvents = true
 whether or not this manager should load data from file on load events More...
 
bool SaveToMemoryButton
 the debug buttons below are only meant to be used at runtime More...
 
bool LoadFromMemoryButton
 
bool SaveToFileButton
 
bool LoadFromFileButton
 
bool DeletePersistencyFileButton
 
DictionaryStringSceneData SceneDatas
 
- Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMPersistenceManager >
bool AutomaticallyUnparentOnAwake
 if this is true, this singleton will auto detach if it finds itself parented on awake More...
 

Static Public Attributes

static string _resourceItemPath = "Persistence/"
 
static string _saveFolderName = "MMTools/"
 
static string _saveFileExtension = ".persistence"
 
- Static Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMPersistenceManager >
static bool HasInstance
 
static T Current
 

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

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

Additional Inherited Members

- Static Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMPersistenceManager >
static T _instance
 
- Properties inherited from MoreMountains.Tools.MMPersistentSingleton< MMPersistenceManager >
static T Instance [get]
 Singleton design pattern More...
 

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< MMPersistenceManager >.

◆ 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()

static 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

◆ DeletePersistencyFileButton

bool MoreMountains.Tools.MMPersistenceManager.DeletePersistencyFileButton

◆ 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: