34 lines
998 B
C#
34 lines
998 B
C#
using System.Threading.Tasks;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
namespace AibisDream.Framework
|
|
{
|
|
internal sealed class ResourceSystemTypographyProfileLoader : ITypographyProfileLoader
|
|
{
|
|
public async Task<TypographyProfile> LoadAsync(string key)
|
|
{
|
|
AsyncOperationHandle<TypographyProfile> handle =
|
|
ResourceSystem.LoadPersistentAsync<TypographyProfile>(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);
|
|
}
|
|
}
|
|
}
|