using System.Threading.Tasks; using UnityEngine.ResourceManagement.AsyncOperations; namespace AibisDream.Framework { internal sealed class ResourceSystemTypographyProfileLoader : ITypographyProfileLoader { public async Task LoadAsync(string key) { AsyncOperationHandle handle = ResourceSystem.LoadPersistentAsync(key); try { await handle.Task; if (handle.Status == AsyncOperationStatus.Succeeded && handle.Result != null) return handle.Result; ResourceSystem.EarlyReleasePersistent(key); return null; } catch { ResourceSystem.EarlyReleasePersistent(key); throw; } } public void Release(string key) { ResourceSystem.EarlyReleasePersistent(key); } } }