Skip to content
Hasan Bayat edited this page Sep 7, 2017 · 1 revision

Welcome to Save Game Free API documentation.

Table of Contents

SaveGame

SaveGame

The main API class to access saving and loading functionally.

SaveGame.Save


SaveGame.Save (string identifier, T obj);

Description

Saves the given object with the given identifier.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
Syntax
SaveGame.Save<T> (string identifier, T obj);
Example
SaveGame.Save<Vector3Save> ("myVector", new Vector3Save (1f, 2f, 3f));

SaveGame.Save (string identifier, T obj, bool encode);

Description

Saves the given object with the given identifier and encodes the result if encoding is enabled.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
  • encode: Whether to encode the data or not. (Encryption)
Syntax
SaveGame.Save<T> (string identifier, T obj, bool encode);
Example
SaveGame.Save<int> ("encryptedInt", 12, true); // Save data with encryption
SaveGame.Save<int> ("normalInt", 15, false); // Save data without encryption
Notes

Make sure to load the encrypted data with encryption enabled, otherwise the data can't be loaded and this might cause problem.


SaveGame.Save (string identifier, T obj, string encodePassword);

Description

Saves the given object with the given identifier, by the given encoding password. The encoding must be enabled by default to use encodePassword.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
  • encodePassword: The encoding password. (Encryption)
Syntax
SaveGame.Save<T> (string identifier, T obj, string encodePassword);
Example
SaveGame.Save<float> ("time", 123f, "12345UP");

SaveGame.Save (string identifier, T obj, ISaveGameSerializer serializer);

Description

Saves the given object with the given identifier and uses the given serializer for serialization.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
  • serializer: The serializer to use for serialization.
Syntax
SaveGame.Save<T> (string identifier, T obj, ISaveGameSerializer serializer);
Example
SaveGame.Save<string> ("myString", "Hello World", new SaveGameXmlSerializer ());
Notes

Make sure to use same serializers for saving and loading, otherwise you might experience some errors.


SaveGame.Save (string identifier, T obj, ISaveGameEncoder encoder);

Description

Saves the given object with the given identifier and uses the given encoder for encryption.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
  • encoder: The encoder, which encryption method to use.
Syntax
SaveGame.Save<T> (string identifier, T obj, ISaveGameEncoder encoder);
Example
SaveGame.Save<int> ("score", 125, new SaveGameSimpleEncoder ());
Notes

Make sure to use same encoder for both saving and loading, otherwise you might experience unexcepted behaviours.


SaveGame.Save (string identifier, T obj, Encoding encoding);

Description

Save the given object with the given identifier with the specified character encoding.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
  • encoding: The character encoding to use.
Syntax
SaveGame.Save<T> (string identifier, T obj, Encoding encoding);
Example
SaveGame.Save<string> ("myString", "Hello, World!", Encoding.UTF8);

SaveGame.Save (string identifier, T obj, SaveGamePath savePath);

Description

Saves the given object with the given identifier at the given path.

Parameters
  • identifier: The identifier.
  • obj: The object to save.
  • savePath: The save path, where to save the data.
Syntax
SaveGame.Save<T> (string identifier, T obj, SaveGamePath savePath);
Example
SaveGame.Save<Vector2Save> ("myVector", new Vector2Save (12f, 42f), SaveGamePath.DataPath);
Notes

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);

Description

Saves the object with using the specified parameters.

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.
Syntax
SaveGame.Save<T> (string identifier, T obj, bool encode, string password, ISaveGameSerializer serializer, ISaveGameEncoder encoder, Encoding encoding, SaveGamePath savePath);
Example
SaveGame.Save<string> ("myString", "Hello, World!", true, "12345", new SaveGameJsonSerializer (), new SaveGameSimpleEncoder (), Encoding.UTF8, SaveGamePath.DataPath);