using System.Collections.Generic; using System.Linq; using Code.Infrastructure.Configs; using Code.Infrastructure.EventBus; using Cysharp.Threading.Tasks; using UnityEngine.AddressableAssets; namespace Code.Calendar.Constants { // Написать кодрайтер, который будет находить конфиги и добавлять их сюда пока написано само public class ConstantImagesService { private readonly EventBus _eventBus; public List Configs { get; private set; } public ConstantImagesService(EventBus eventBus, IConfigLocator configLocator) { _eventBus = eventBus; var label = configLocator.TryGetManyConfigAssetReferences(); LoadImage(label).Forget(); } private async UniTaskVoid LoadImage(string imagesLabel) { if ((await Addressables.LoadResourceLocationsAsync(imagesLabel).Task).Count != 0) { var images = Addressables.LoadAssetsAsync(imagesLabel, null, Addressables.MergeMode.Union); await images.ToUniTask(); Configs = images.Result.ToList(); } _eventBus.RaiseEvent(x=> x.ImagesLoaded()); } } public interface IConstantImagesServiceHandle : IGlobalSubscriber { void ImagesLoaded(); } }