using System; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; namespace DDD { public class AssetManager : Singleton, IManager { public void Init() { } public async void PostInit() { try { await Addressables.InitializeAsync().Task; } catch (Exception e) { Debug.Assert(false, "Addressables initialization failed"); } } public static async Awaitable LoadAsset(string key) where T : UnityEngine.Object { var handle = Addressables.LoadAssetAsync(key); await handle.Task; if (handle.Status == AsyncOperationStatus.Succeeded) return handle.Result; Debug.LogError($"Addressable load failed : {key}"); return null; } } }