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 _configsResourcesPaths = new (PathToResources.ScriptableObject); public ResourcesConfigsLoader(ResourcesAssetsLoader resources) { _resources = resources; } public IEnumerator LoadAsync(Action> onConfigsLoaded) { Dictionary loadedConfigs = new(); foreach (KeyValuePair configResourcesPath in _configsResourcesPaths) { ScriptableObject config = _resources.Load(configResourcesPath.Value); loadedConfigs.Add(configResourcesPath.Key, config); yield return null; } onConfigsLoaded?.Invoke(loadedConfigs); } } }