Files
project-entity/Assets/_Project/Develop/Runtime/Utilities/ConfigsManagement/ResourcesConfigsLoader.cs
2026-02-18 23:02:28 +05:00

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);
}
}
}