Important
This plugin is designed to save/restore existing game data files. It does not include save system functionalities such as data serialization or deserialization.
A Unity plugin for saving and restoring game data (persistent data).
- Save game data (persistent data).
- Restore saved game data.
- Manage data via a clean, easy-to-read UI.
- Use data saved in the Editor on actual devices.
When verifying "items with a 1% drop rate" or "events triggered under specific conditions," restarting the game from the beginning is a waste of time. By saving the state immediately before the check and loading it after the check to retry repeatedly, you can verify the behavior of low-probability events dozens of times in a short period.
This is useful in RPGs or adventure games when you want to test both "Option A" and "Option B." By saving the state just before a branching point, you can check one route and then immediately return to check the other, minimizing backtracking during debugging.
When testers find a bug, reproducing "how that state was reached" is often difficult. Since this plugin works on actual devices, by saving periodically, you can rewind to the moment a bug occurred. This makes it easy to share the exact occurrence context with developers or identify reproduction steps.
Useful for situations like adjusting boss difficulty, where you want to "slightly increase attack power and retry." By preserving the state before the battle starts, adjusting enemy parameters in the Inspector, and repeating the "Restore & Retry" process, you can efficiently find the ideal game balance.
When performing integration tests, you often need specific states like "1000G, Level 10." Instead of setting up from new data every time, restoring an "ideal state" created in advance with this plugin allows you to start testing immediately, significantly reducing execution time and ensuring a clean testing environment.
"Unity Editor : Window > Package Manager > Add package from git URL...".
https://github.com/IShix-g/HistoryTracker.git?path=Packages/HistoryTracker#v1
Implement IHistSaveDataHandler to link your save system with HistoryTracker.
| Method | Description |
|---|---|
| OnBeforeSave() | Called immediately before saving. Save necessary game data and return the title and description. This content will be displayed in the UI. |
| GetSaveFilePaths() | Returns an array of full paths to game data files. e.g., Application.persistentDataPath + "/data.bytes" |
| ApplyData() | Called after game data has been restored. Reflect the game data by reloading it or by calling Application.Quit() to close the app once. |
using HistoryTracker;
public sealed class TestModelRepository : ModelRepository, IHistSaveDataHandler
{
public HistRecordInfo OnBeforeSave()
{
// Save data
for (var i = 0; i < Models.Count; i++)
{
var model = Models[i];
var path = GetFullPath(model.Id);
Save(model, path);
}
// Return the title and description
var title = "Saved Count: " + Models[0].SaveCount;
var description = "[Test]";
return new HistRecordInfo(title, description);
}
// Determine and return the file path
// e.g. `Application.persistentDataPath` + "/data.bytes"
public IReadOnlyList<string> GetSaveFilePaths() => Paths.Values.ToList();
public void ApplyData() => Restored();
}The title and description set in OnBeforeSave() above will be displayed in the UI as follows:
var title = "Saved Count: " + Models[0].SaveCount;
var description = "[Test]";
return new HistRecordInfo(title, description);Set the IHistSaveDataHandler implemented above to HistoryTracker. Configure it in Awake as early as possible after
the game starts.
void Awake()
{
// Initialize the repository that implements IHistSaveDataHandler in Awake
Hist.Configure(_repository);
}The dialog is opened via script. You can release it by calling Hist.Release() when it's no longer needed, but since
it's lightweight, this is unlikely to cause any issues.
using HistoryTracker;
void OnDialogButtonClicked()
{
Hist.OpenDialog();
}Displays a list of saved history.
| No | Description |
|---|---|
| ① | Save Game Data |
| ② | Record Count |
| ③ | Saved Game Data Item |
| ④ | Open Details |
| ⑤ | Previous Page |
| ⑥ | Next Page |
| ⑦ | Close |
Details and operations for saved game data.
| No | Description |
|---|---|
| ① | Restore Game Data |
| ② | Delete Game Data |
| ③ | Title (Long press to edit) * |
| ④ | Description (Long press to edit) * |
| ⑤ | List of saved file paths |
| ⑥ | Badge displayed if saved in Editor |
| ⑦ | Close |
| ⑧ | Date Saved |
- Note: On actual devices, you cannot edit data generated in the Editor.
By default, this plugin operates only in the debug environment. You can adjust this in the settings.
| No | Description |
|---|---|
| ① | Show GitHub Page (External Link) |
| ② | Open History Dialog (Runtime only) |
| ③ | Plugin Scope (EditorOnly / DevelopmentBuild / All) |
| ④ | Use game data saved in Editor on actual device? |
While you can save game data using the Save button in the History Dialog, you can also save via code using the snippet below:
Hist.SaveHistory();If your save system has level-up events, saving game data each time you level up makes it easier to revert if issues occur.
Code Example:
void OnLevelUp(int level)
{
// You can add a title and description.
var title = $"Level Up {level}";
var description = JsonUtility.ToJson(_user, true);
var info = new HistRecordInfo(title, description);
Hist.SaveHistory(info);
}To use the pre-prepared code, execute the following. This is a singleton component that monitors for errors and calls
Hist.SaveHistory().
Code Example:
void Start()
{
HistErrorSaver.Create();
}Resources.Load - Used for loading UI assets at runtime on actual devices (e.g., mobile phones). Assets loaded via this API are only included in the final game build if the associated plugin is enabled. If the plugin is disabled, the assets are omitted (stripped) and will not be packaged with the application.