Example Usage
Using GSUIResourceBase
[SerializeField] private GSUITimeBase _coolTime;
// this is for saving last updated time
_coolTime.OnTimeChanged += OnTimeChanged;
// you need to set last updated time either from local or from your server saved value before use
_coolTime.SetLastUpdateTime(energyUpdateTime);
// this will return true if time is passed
_coolTime.IsTimePassed();
// to start the timer, call this. As this is ScriptableObject, you can call this code from anywhere if the code has reference
_coolTime.UpdateLastUpdateTime();
Using GSUITimeResource
[SerializeField] private GSUITimeResource _energy;
// this is for saving last updated time
_energy.OnTimeChanged += OnTimeChanged;
// this is for saving current changed amount
_energy.OnAmountChanged += OnEnergyChanged;
// you need to set last updated time either from local or from your server saved value before use
_energy.SetLastUpdateTime(energyUpdateTime);
// you need to set current amount either from local or from your server saved value before use
_energy.current = PlayerPrefs.GetFloat(ENERGY_AMOUNT_KEY, _energy.max);
// you need to call either one of these codes to update the amount based on your setting.
_energy.UpdateCachedTimeSpan();
_energy.GetRemainingTimeFormatted();
Last updated