Files
plugin-library/Assets/00.StaryEvo/~Samples/Runtime/CounterApp/Script/CounterModel.cs
2025-03-31 11:19:27 +08:00

32 lines
684 B
C#

namespace Stary.Evo.Example.Counter
{
public interface ICounterData : IData
{
BindableProperty<int> Count { get; }
}
public class CounterData : AbstractData, ICounterData
{
public override void Dispose()
{
}
protected override void OnInit()
{
var storage = this.GetUtility<IStorage>();
Count.Value = storage.LoadInt("COUNTER_COUNT", 0);
Count.Register( count => { storage.SaveInt("COUNTER_COUNT", count); });
}
public BindableProperty<int> Count { get; } = new BindableProperty<int>()
{
Value = 0
};
}
}