Files
2026-02-18 23:02:28 +05:00

29 lines
894 B
C#

using System.Collections;
using Assets._Project.Develop.Runtime.Utilities.DataManagement;
using Assets._Project.Develop.Runtime.Utilities.DataManagement.DataProviders;
using UnityEngine;
namespace _Project.Develop.Runtime.Utilities.DataManagement
{
public static class DataUtils
{
public static IEnumerator LoadProviderAsync<T>(DataProvider<T> data) where T : ISaveData
{
bool isDataSaveExists = false;
yield return data.ExistsAsync(result => isDataSaveExists = result);
if (isDataSaveExists)
{
yield return data.LoadAsync();
Debug.Log($"Data {typeof(T).Name} loaded");
}
else
{
data.Reset();
yield return data.SaveAsync();
Debug.Log($"Data {typeof(T).Name} created");
}
}
}
}