Class ProfileSerializer
- Namespace
- TDMaker.Unity.Campaign
- Assembly
- TDMaker.Unity.dll
JSON form of ProfileData with schema versions. Reading runs the built-in migration steps and then every registered Migrate step from the file's version up to CurrentVersion (JsonUtility leaves fields a file does not have at their defaults, so a step only fixes meaning, not shape).
public static class ProfileSerializer
- Inheritance
-
ProfileSerializer
- Inherited Members
Properties
RegisteredMigrations
A copy of the registered migration steps (for diagnostics).
public static IReadOnlyList<Delegate> RegisteredMigrations { get; }
Property Value
Methods
Read(string, out ProfileData, out string)
Reads json. Returns Loaded or Migrated with the data,
Empty for empty text, Corrupt for text that is not a profile and
NewerVersion for a schema this code does not know. Never throws.
public static SaveLoadStatus Read(string json, out ProfileData data, out string error)
Parameters
jsonstringdataProfileDataerrorstring
Returns
ToJson(ProfileData, bool)
The JSON text of data (stamped with the current version).
public static string ToJson(ProfileData data, bool pretty = true)
Parameters
dataProfileDataprettybool
Returns
Events
Migrate
Extra migration steps for your own data (for example values you keep in custom). Called once per version step, after the built-in step, with the version the data had before the step.
public static event ProfileMigration Migrate