Samples

The samples import from Package Manager → PersistKit → Samples → (pick one) → Import. Each one compiles against the package as it is, with nothing else to install.

01 Quick Start#

FileWhat it shows
QuickStartScore.csSaving and loading a number, with the default a new player gets, and a result checked
QuickStartProfile.csSaving a data class, a list and a dictionary, and loading them back the next time the game runs
README.mdWhat to press, in what order, and what you should see

Drop both scripts on an empty GameObject in a new scene, press Play, then read the Console. Stop and press Play again: the values come back.

02 Automatic Saving#

FileWhat it shows
AutoSaveDemo.csA game that saves itself: the component on a timer, the game's own data saved through SaveNow() and Checkpoint(), and the result read back
README.mdWhat to press, what to expect in the Console, and what the Inspector panel says while it runs

Shows the one save path: automatic saves and asked-for saves go through the same call, so nothing is written twice.

03 Save Menu#

FileWhat it shows
SaveMenuDemo.csA finished save/load menu with no UI authored: several saved games, each with a picture, a timestamp, playtime, a chapter label and Save, Load and Delete — and Delete asks first
README.mdHow to open it, what a row shows, and how your own code answers SaveRequested and LoadRequested

04 Offline Progress#

FileWhat it shows
OfflineProgressDemo.csAn idle game working out how long the save was away: a cap on what a session is worth, a clock-rollback report, and the exact code for each way the time can look wrong
README.mdHow to run it twice with a pause in between, and how to change the clock policy

05 Clicker: idle progression#

A complete scene, not a script to assemble: open Scenes/ClickerIdleProgress.unity and press Play.

FileWhat it shows
Scenes/ClickerIdleProgress.unityThe scene: the rock, the camera, the light, the panel and the five buttons, all wired
Scripts/ClickerDemo.csA playable clicker: tap to mine, level up, save, and a welcome-back line that pays what was earned while the game was closed — with PersistKit's cap and the clock-rollback case stated rather than hidden
Materials/Ore.matThe rock's material
README.mdWhat to press, how to see an offline payout, and why the award is capped

06 Physics sandbox#

A complete scene: open Scenes/PhysicsSandbox.unity and press Play.

FileWhat it shows
Scenes/PhysicsSandbox.unityThe scene: floor, four walls, a starting stack of crates, the camera and the button bar
Scripts/PhysicsSandboxDemo.csCrates spawned from a prefab, saved as a set, put back where physics left them — and retired when the player sweeps them away, so a later load does not rebuild them
Prefabs/Crate.prefabThe crate that gets spawned. It carries a PersistKit Behaviour remembering its position and rotation, which is how a spawned crate remembers where it was
Resources/PersistKit/The registry that names the prefab, shipped in a Resources folder, so there is nothing to wire
Materials/The floor, wall and crate materials
README.mdThe order to press things in, and why Clear then Load is the interesting case

07 Top-down RPG#

A complete scene: open Scenes/TopDownRpg.unity and press Play.

FileWhat it shows
Scenes/TopDownRpg.unityThe scene: ground, rocks, the player capsule, the two area markers and the button bar
Scripts/TopDownRpgDemo.csA small top-down world with three save slots through the real runtime save menu: timestamp, playtime, the area it was saved in, and a thumbnail
Materials/The ground, rock, player and marker materials
README.mdWalk, save into a slot, load it again, and see that overwriting and deleting ask first

What is not here yet#

Not supported There is no sample for cloud providers or for migrations: the cloud pages carry a copyable provider, and the migration page carries a worked example, because both need a service or an older build to be worth anything as a sample. Nothing on this page is a placeholder — every sample listed above imports, runs and has its save/load behaviour watched.

Writing your own first sample#

If you would rather build one yourself, the shortest path is the five-minute quick start, then the no-code guide for an object in a scene, and then cloud saves if you want a copy somewhere else.