mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
|
|
using UnityEngine;
|
|
|
|
namespace Assets._Project.Develop.Runtime.Utilities.ConfigsManagement
|
|
{
|
|
public class ResourcesConfigsLoader : IConfigsLoader
|
|
{
|
|
private readonly ResourcesAssetsLoader _resources;
|
|
|
|
private readonly Dictionary<Type, string> _configsResourcesPaths = new (PathToResources.ScriptableObject);
|
|
|
|
public ResourcesConfigsLoader(ResourcesAssetsLoader resources)
|
|
{
|
|
_resources = resources;
|
|
}
|
|
|
|
public IEnumerator LoadAsync(Action<Dictionary<Type, object>> onConfigsLoaded)
|
|
{
|
|
Dictionary<Type, object> loadedConfigs = new();
|
|
|
|
foreach (KeyValuePair<Type, string> configResourcesPath in _configsResourcesPaths)
|
|
{
|
|
ScriptableObject config = _resources.Load<ScriptableObject>(configResourcesPath.Value);
|
|
loadedConfigs.Add(configResourcesPath.Key, config);
|
|
yield return null;
|
|
}
|
|
|
|
onConfigsLoaded?.Invoke(loadedConfigs);
|
|
}
|
|
}
|
|
} |