mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
init: add project
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user