The Save System API
Note
This article is mostly for intermediate users who can understand code and programming.
Introduction
The Save System API allows you to manually manage your data easily by accessing a few methods, but before using the API you need to know a few things:
What is an identifier?
An identifier is a string that lets you specify the file name, entity name, or path of your data in the specified Storage.
For example, in a File storage the identifier is the path to the file, that means you can provide an absolute path to the file or a relative path which is relative to the Unity's persistent data path.
But in a web based storage, the identifier might indicate the key inside a database or again a path to a file which depends on the storage implementation.
What is the catalog?
The catalog is a file created at the storage's base path that holds a list of all the saved items and identifiers for performing certain actions on them later using different API methods such as Listing items or restoring backups.
What is the meta data?
The meta data is an identifier created alongside the provided identifier which often has a .meta
suffix at the end of the original identifier that holds special information and details about the data, the default Storages contain the below meta data:
- CreationTimeUtc: the creation time of the original identifier in UTC
- LastModificationTimeUtc: the last modification time of the original identifier in UTC (only by the Save System)
- LastAccessTimeUtc: the last access time of the original identifier in UTC (only by the Save System)
- Encrypted: whether or not the original identifier is encrypted
- ApplicationVersion: the unity application version
Application.version
The meta data suffix is defined by the Storage implementation, so if you want to have a custom meta suffix, you need to implement a custom storage and then use a custom suffix.
Usage
The Save System API is Asynchronous and uses the C# Async/Await system, so in order to use the API methods, you need to use await
keyword usually:
await SaveSystemAPI.SaveAsync(identifier, obj);
By the given example above, the SaveAsync
method saves the given object obj
to the specified identifier (it would be a file path if the storage is local disk).
You can also pass a SaveSystemSettings
parameter to the most of the API methods as the last parameter:
await SaveSystemAPI.SaveAsync(identifier, obj, mySettings);