-
-
Notifications
You must be signed in to change notification settings - Fork 59
API
Welcome to Save Game Free API documentation.
The main API class to access saving and loading functionally.
Saves the given object with the given identifier.
- identifier: The identifier.
- obj: The object to save.
SaveGame.Save<T> (string identifier, T obj);
SaveGame.Save<Vector3Save> ("myVector", new Vector3Save (1f, 2f, 3f));
Saves the given object with the given identifier and encodes the result if encoding is enabled.
- identifier: The identifier.
- obj: The object to save.
- encode: Whether to encode the data or not. (Encryption)
SaveGame.Save<T> (string identifier, T obj, bool encode);
SaveGame.Save<int> ("encryptedInt", 12, true); // Save data with encryption
SaveGame.Save<int> ("normalInt", 15, false); // Save data without encryption
Make sure to load the encrypted data with encryption enabled, otherwise the data can't be loaded and this might cause problem.
Saves the given object with the given identifier, by the given encoding password. The encoding must be enabled by default to use encodePassword.
- identifier: The identifier.
- obj: The object to save.
- encodePassword: The encoding password. (Encryption)
SaveGame.Save<T> (string identifier, T obj, string encodePassword);
SaveGame.Save<float> ("time", 123f, "12345UP");
Saves the given object with the given identifier and uses the given serializer for serialization.
- identifier: The identifier.
- obj: The object to save.
- serializer: The serializer to use for serialization.
SaveGame.Save<T> (string identifier, T obj, ISaveGameSerializer serializer);
SaveGame.Save<string> ("myString", "Hello World", new SaveGameXmlSerializer ());
Make sure to use same serializers for saving and loading, otherwise you might experience some errors.
Saves the given object with the given identifier and uses the given encoder for encryption.
- identifier: The identifier.
- obj: The object to save.
- encoder: The encoder, which encryption method to use.
SaveGame.Save<T> (string identifier, T obj, ISaveGameEncoder encoder);
SaveGame.Save<int> ("score", 125, new SaveGameSimpleEncoder ());
Make sure to use same encoder for both saving and loading, otherwise you might experience unexcepted behaviours.
Save the given object with the given identifier with the specified character encoding.
- identifier: The identifier.
- obj: The object to save.
- encoding: The character encoding to use.
SaveGame.Save<T> (string identifier, T obj, Encoding encoding);
SaveGame.Save<string> ("myString", "Hello, World!", Encoding.UTF8);
Saves the given object with the given identifier at the given path.
- identifier: The identifier.
- obj: The object to save.
- savePath: The save path, where to save the data.
SaveGame.Save<T> (string identifier, T obj, SaveGamePath savePath);
SaveGame.Save<Vector2Save> ("myVector", new Vector2Save (12f, 42f), SaveGamePath.DataPath);
Make sure to use same Save Path for both saving and loading, otherwise the data can't be loaded.
SaveGame.Save (string identifier, T obj, bool encode, string password, ISaveGameSerializer serializer, ISaveGameEncoder encoder, Encoding encoding, SaveGamePath savePath);
Saves the object with using the specified parameters.
- identifier: The identifier.
- obj: The object to save.
- encode: Whether to encode the data or not. (Encryption)
- password: The encoding password. (Encryption)
- serializer: The serializer to use for serialization.
- encoder: The encoder, which encryption method to use.
- encoding: The character encoding to use.
- savePath: The save path, where to save the data.
SaveGame.Save<T> (string identifier, T obj, bool encode, string password, ISaveGameSerializer serializer, ISaveGameEncoder encoder, Encoding encoding, SaveGamePath savePath);
SaveGame.Save<string> ("myString", "Hello, World!", true, "12345", new SaveGameJsonSerializer (), new SaveGameSimpleEncoder (), Encoding.UTF8, SaveGamePath.DataPath);