Makinom allows you to add custom save data to the save game system.
Add custom save data (e.g. 3rd party product data) to Makinom save games by registering a class (e.g. a component) to the save game system. The class must implement the ISaveData interface.
To register a class, call the following function:
The parameters of the function:
If you want to unregister a class from the save game handler, you can call the following function:
Please note that only registered save data can be saved or loaded, i.e. you have to register your classes before saving or loading the game. This is best done in the scene you also initialize Makinom via a game starter.
This interface has two functions that need to be implemented into your class:
This function is called when the game is saved. It returns a DataObject, which holds all the data that you want to save.
This function is called when a save game is loaded. The DataObject passed as parameter contains the data that is saved. It’s crucial to make a check for null on the data object before using it, since it could be null if no data was found for the registered name – in that case, you can use the load game function to do default initialization.
Here’s a small code example on how the custom save data functionality can be used. The example uses a component (MonoBehaviour), but you can also use similar code in other classes.
It’s crucial that the class you register to the save game handler must be alive throughout the entire game, and it’s best if you register it in the same scene where Makinom is first initialized with a game starter. Don’t register custom save data in a running game, this will lead to the classes not being registered if you play the game at a later time and want to load a save game.
You can also save the data from classes within your custom save game data by implementing the ISaveData interface in the class. This allows creating complex save game structures.
To add the data of a class to your custom save data:
To load the data of a class from your custom save data:
Naturally you can also save classes within classes, within classes …
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!