Files
plugin-library/Assets/00.StaryEvo/~Samples/Runtime/CounterApp/Script/CounterModel.cs

32 lines
684 B
C#
Raw Normal View History

2025-03-31 11:16:52 +08:00
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
};
}
}