Show / Hide Table of Contents

Class PersistentData

Used for storing data even after the editor has been reloaded

Inheritance
object
PersistentData
Namespace: WeaverCore.Editor.Compilation
Assembly: WeaverCore.Editor.dll
Syntax
public static class PersistentData

Fields

| Edit this page View Source

PersistentDataPath

The file path where persistent data is stored

Declaration
public static string PersistentDataPath
Field Value
Type Description
string

Properties

| Edit this page View Source

AutoSave

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 Source

ContainsData(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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

SaveData()

Saves the stored data to the PersistentDataPath

Declaration
public static void SaveData()
| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾