mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 15:51:10 +00:00
29 lines
894 B
C#
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");
|
|
}
|
|
}
|
|
}
|
|
} |