Game Data Maker is a simple implementation of data saving and loading to a binary file. It provides a simple configuration editor, methods for saving, loading and deleting and callbacks on success or failure for each of those methods.
Download this package to your disk. Open the package manager on Window > Package Manager and select the + button and click on the Add package from disk... option.
- Add the GameDataMaker package.
Open the project manifest file under the Packages folder and add these lines to the dependencies:
"dependencies": {
"com.loophouse.game-data-maker":"https://github.com/luisoliveiras/game-data-maker.git",
}
Open the package manager on Window > Package Manager and select the + button and click on the Add package from git URL... option.
- Add the GameDataMaker package from: https://github.com/luisoliveiras/game-data-maker.git
* You can also add it from disk if you want, just follow the steps from 2018.4 install guide.
Access the menu Tools > Game Data Maker to open the game Data Maker configuration editor. If no SaveConfig File was created it will create a new one under Assets > Resources.
Show Logs: Use the Show Logs checkbox to enable/disable the logs from the Game Data Maker.
Game Data Items: The game data items represents a file and path where it will be saved. The Name property used to access it from code. The Path contains a folder (optional), a file name and a extension, and defines where the file will be saved and loaded from.
* The CustomPath class uses the Application.persistentDataPath to define the parent folder of the file.
The GameDataManager is the class used to access the save data and have 3 main methodsfor that:
Save: void Save<T>(T data, string item)
Serializes T to a binary file (T and its attributes must be serializable) in the path set for the item (name of the Game Data Item in the config file). Invokes OnSaveSuccess when the file is successfully saved, and OnSaveFail when there is a problem.
Load: T Load<T>(string item)
Deserializes the file from the path set for the item. Invokes OnLoadSuccess when the file is successfully loaded and OnLoadFail when there is a problem loading the file.
Delete: void Delete(string item)
Deletes the file from the path set for the item. Invokes OnDeleteSuccess when it deletes the file and OnDeleteFail when it is unable to delete it.
What: Contains a basic implementation of save, load and delete, using the Game Data Maker tool.
How: Import the Example 01 sample from the Package Manager UI. Open the Example01 scene inside the folder added to your project's Assets folder and you're ready to go.