30 lines
830 B
C#
30 lines
830 B
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine.AddressableAssets;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
namespace Code.Infrastructure.Utils
|
|
{
|
|
public static class AddressablesUtilities
|
|
{
|
|
public static async UniTask<bool> CheckLabelExists(string labelName)
|
|
{
|
|
if (labelName is null) return false;
|
|
|
|
var handle = Addressables.LoadResourceLocationsAsync(labelName);
|
|
|
|
await handle.ToUniTask();
|
|
|
|
if (handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
if (handle.Result.Count > 0)
|
|
{
|
|
Addressables.Release(handle);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
Addressables.Release(handle);
|
|
return false;
|
|
}
|
|
}
|
|
} |