Class SaveStateUtility
Utility for saving and loading simulation states as well as particle configuration templates.
A simulation state comprises the entire history of all particles in
the system. It is stored in a SimulationStateSaveData
object, which can be serialized and deserialized by Unity's
JsonUtility
.
Similarly, InitModeSaveData objects represent the system state in Initialization Mode.
Inheritance
Namespace: AS2
Assembly: .dll
Syntax
public static class SaveStateUtility
Fields
| Edit this page View SourcedefaultSaveFile
Default file for saving simulation states.
Declaration
public static string defaultSaveFile
Field Value
Type | Description |
---|---|
string |
tmpSaveFile
Temporary save file used to restore simulation when Init Mode is aborted.
Declaration
public static string tmpSaveFile
Field Value
Type | Description |
---|---|
string |
Methods
| Edit this page View SourceLoad(string)
Loads a simulation state from a save file.
Declaration
public static SimulationStateSaveData Load(string filename = null)
Parameters
Type | Name | Description |
---|---|---|
string | filename | The file from which to read the save data. Default value is defaultSaveFile. |
Returns
Type | Description |
---|---|
SimulationStateSaveData | The serializable object representation of the data stored in the
given file. Can be |
LoadInit(string)
Loads an initialization state from a save file.
Declaration
public static InitializationStateSaveData LoadInit(string filename = null)
Parameters
Type | Name | Description |
---|---|---|
string | filename | The file from which to read the save data. Default value is defaultSaveFile. |
Returns
Type | Description |
---|---|
InitializationStateSaveData | The serializable object representation of the data stored in the
given file. Can be |
Save(SimulationStateSaveData, string, bool)
Converts the given simulation state to JSON format and writes it to a file.
Declaration
public static bool Save(SimulationStateSaveData data, string filename = null, bool prettyPrint = false)
Parameters
Type | Name | Description |
---|---|---|
SimulationStateSaveData | data | The serializable representation of the simulation state. |
string | filename | The file in which to store the JSON string. Default value is defaultSaveFile. |
bool | prettyPrint | If |
Returns
Type | Description |
---|---|
bool |
|
SaveInit(InitializationStateSaveData, string, bool)
Converts the given initialization state to JSON format and writes it to a file.
Declaration
public static bool SaveInit(InitializationStateSaveData data, string filename = null, bool prettyPrint = false)
Parameters
Type | Name | Description |
---|---|---|
InitializationStateSaveData | data | The serializable representation of the initialization state. |
string | filename | The file in which to store the JSON string. Default value is defaultSaveFile. |
bool | prettyPrint | If |
Returns
Type | Description |
---|---|
bool |
|