Class PersistentData
Used for storing data even after the editor has been reloaded
Namespace: WeaverCore.Editor.Compilation
Assembly: WeaverCore.Editor.dll
Syntax
public static class PersistentData
Fields
| Edit this page View SourcePersistentDataPath
The file path where persistent data is stored
Declaration
public static string PersistentDataPath
Field Value
Type | Description |
---|---|
string |
Properties
| Edit this page View SourceAutoSave
Whether to autosave after making a call to StoreData<T>(T, PersistenceType)
Declaration
public static bool AutoSave { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceContainsData(string)
Checks if data is being stored under the specified key
Declaration
public static bool ContainsData(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key the data is be stored under |
Returns
Type | Description |
---|---|
bool | Returns true if data of the specified type is currently being stored |
ContainsData<T>()
Is data of the specified type currently being stored?
Declaration
public static bool ContainsData<T>()
Returns
Type | Description |
---|---|
bool | Returns true if data of the specified type is currently being stored |
Type Parameters
Name | Description |
---|---|
T | The type of data to load |
LoadData<T>()
Loads some stored data
Declaration
public static T LoadData<T>()
Returns
Type | Description |
---|---|
T | Returns the loaded data, or null/default if not |
Type Parameters
Name | Description |
---|---|
T | The type of data to load |
LoadData<T>(string)
Loads some stored data
Declaration
public static T LoadData<T>(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key the data is be stored under |
Returns
Type | Description |
---|---|
T | Returns the loaded data, or null/default if not |
Type Parameters
Name | Description |
---|---|
T | The type of data to load |
RemoveData(string)
If data of the specified key is currently being stored, this function removes it
Declaration
public static bool RemoveData(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key to remove |
Returns
Type | Description |
---|---|
bool | Returns true if data has been removed |
RemoveData<T>()
If data of the specified type is currently being stored, this function removes it
Declaration
public static bool RemoveData<T>()
Returns
Type | Description |
---|---|
bool | Returns true if data has been removed |
Type Parameters
Name | Description |
---|---|
T | The type of data to remove |
SaveData()
Saves the stored data to the PersistentDataPath
Declaration
public static void SaveData()
StoreData<T>(T, string, PersistenceType)
Stores some data so it will survive even after the unity editor has been reloaded
Declaration
public static void StoreData<T>(T data, string key, PersistenceType persistenceType = PersistenceType.Forever)
Parameters
Type | Name | Description |
---|---|---|
T | data | The data to store |
string | key | The key the data will be stored under |
PersistenceType | persistenceType | How the data should be stored |
Type Parameters
Name | Description |
---|---|
T | The type of data to store |
StoreData<T>(T, PersistenceType)
Stores some data so it will survive even after the unity editor has been reloaded
Declaration
public static void StoreData<T>(T data, PersistenceType persistenceType = PersistenceType.Forever)
Parameters
Type | Name | Description |
---|---|---|
T | data | The data to store |
PersistenceType | persistenceType | How the data should be stored |
Type Parameters
Name | Description |
---|---|
T | The type of data to store |
TryGetData<T>(string, out T)
Attempts to get some persistent data
Declaration
public static bool TryGetData<T>(string key, out T data)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key the data is stored under |
T | data | The output data |
Returns
Type | Description |
---|---|
bool | Returns whether data of the specific type has been stored away |
Type Parameters
Name | Description |
---|---|
T | The type of data to retrieve |
TryGetData<T>(out T)
Attempts to get some persistent data
Declaration
public static bool TryGetData<T>(out T data)
Parameters
Type | Name | Description |
---|---|---|
T | data | The output data |
Returns
Type | Description |
---|---|
bool | Returns whether data of the specific type has been stored away |
Type Parameters
Name | Description |
---|---|
T | The type of data to retrieve |