Interface IVersionedData
Opt-in schema check for a preset data type. Load<T>(string) refuses a document whose Version this build does not read, so a file written by a newer build is reported as a version mismatch rather than loaded with some of its fields silently wrong.
public interface IVersionedData
Expand Details ...
Remarks
Both members are implemented explicitly, and that is load-bearing rather than stylistic.
A get-only property is neither written by JsonUtility.ToJson nor read by
JsonUtility.FromJson, so implementing this interface adds no key to any saved preset and
leaves the P7 JSON preset schema unchanged. An implementing type keeps its existing serialized
Version field and forwards to it.
Why refusing is right, rather than warning and loading anyway: the damage a too-new document
does is silent. JsonUtility writes 0 into a field whose type changed, keeps an
unknown enum ordinal verbatim without raising anything, and ignores a key it does not
recognise — so "warn and continue" leaves a half-correct parameter set animating a character
with no way to tell which fields survived. A refusal naming both version numbers is fully
recoverable, because the user still has the file.
The check lives in SaveSystem rather than in each caller because there are
three callers today and more later, and it is gated on this interface rather than imposed on
every T because a type with no schema of its own has no version to check.
Properties
SupportedVersion
Highest Version this build can read. Anything above it is refused.
int SupportedVersion { get; }
Property Value
- int
Version
Format version the document being read carries.
int Version { get; }
Property Value
- int