Save variable values serialized by Json.NET to a specified file, or load it back. More...
Inherits MonoBehaviour.
Public Member Functions | |
void | Save () |
Save all variable values in a text file. More... | |
bool | Load () |
Load and apply all variable values from file. More... | |
Static Public Member Functions | |
static string | Serialize (bool readable, params VariableInfo[] variables) |
Serialize all variable values to a JSON string . More... | |
static void | Deserialize (string json, params VariableInfo[] variables) |
Deserialize a JSON string generated by Serialize() . More... | |
static string | GetTargetText (VariableInfo variable) |
Get the text describes the target of specified VariableInfo . More... | |
static string | GetTooltipText (VariableInfo variable) |
Get the text of the tooltip attribute of specified VariableInfo . More... | |
static string | GetMemberText (VariableInfo variable, bool type=true) |
Get the text describes the member of specified VariableInfo . More... | |
Public Attributes | |
bool | reloadOnAwake = true |
Flag if to auto load and save when Awake() . More... | |
string | file |
The unique file path to save and load values. More... | |
bool | encrypt |
Flag if save values with encrypted text. More... | |
Properties | |
VariableInfo[] | variables [get] |
Get all the VariableInfo of this. More... | |
Save variable values serialized by Json.NET to a specified file, or load it back.
Variable could be a field or property of a UnityEngine.Component
, or a static one of some runtime type. It's also able to drag objects to the list to select multiple variables.
|
static |
Serialize all variable values to a JSON string
.
Optional to format to an indented multiline text with readable variable information. Otherwise, return a single line text include value series only.
readable | If set to true readable. |
variables | Variables. |
|
static |
Deserialize a JSON string
generated by Serialize()
.
Deserialize values in turn to apply all variables. This'll throw a combined exception at last if any failed, for partial valid apply done.
json | JSON string. |
variables | Variables. |
|
static |
Get the text describes the target of specified VariableInfo
.
Return name or path of UnityEngine.Object
, otherwise type name.
variable | Variable. |
|
static |
Get the text of the tooltip attribute of specified VariableInfo
.
variable | Variable. |
|
static |
Get the text describes the member of specified VariableInfo
.
Include member name, and the index if reflect to array element. Optional to append value type, and enum values if it is.
variable | Variable. |
type | If set to true append value type name. |
void Save | ( | ) |
Save all variable values in a text file.
The load operation depends on the order of content in the result file. Be careful while editing the file manually in need.
bool Load | ( | ) |
Load and apply all variable values from file.
Return false
silently if file not existed, otherwise return if all applied. The operation depends on the order of content in the source file. Be careful while editing the file manually in need.
true
if all values is deserialized and set.bool reloadOnAwake = true |
Flag if to auto load and save when Awake()
.
string file |
The unique file path to save and load values.
bool encrypt |
Flag if save values with encrypted text.
|
get |
Get all the VariableInfo
of this.
This guarantees every element within is existed and read-writable. Otherwise, throw exception when generating. It's better to check VariableInfo.isValid
before accessing it in need.