Description
This scene implements a simple Idle Game that supports persistence by saving the points & auto-clicker count in PlayerData.
How it works
The main script is IdleGame.cs
, it takes care of the whole gameplay as well as saving and loading.
The only other script, IdleGameButton.cs
is used to communicate the button click to the main script.
Whenever the button is clicked, one point is added to the counter and is saved in PlayerData under the POINTS_KEY string value. Similarly when buying an auto-clicker the points are deducted & saved and a new counter is incremented for auto-clickers, then saved to PlayerData using the AUTOCLICKERS_KEY string value.
The script runs a loop every second to add points using the amount of auto-clickers purchased, the price of the auto-clickers is multiplied by a static amount for every purchase typical of an idle game.
Reloading the scene loads the points & auto-clickers value using the keys and calculates the auto-clicker price.
How to use this example
Load the scene and tweak the Udon values on the “IdleGame” object if you so wish.
Play the scene and collect some cheese, buy some auto-clickers, leave play mode and observe that the values are saved under their respective keys in the ClientSim Player Data window.