using UnityEngine.AddressableAssets;
///
/// A utility class for various Addressables functionality
///
public static class AddressablesUtility
{
///
/// Get the address of a given AssetReference.
///
/// The AssetReference you want to find the address of.
/// The address of a given AssetReference.
public static string GetAddressFromAssetReference(AssetReference reference)
{
var loadResourceLocations = Addressables.LoadResourceLocationsAsync(reference);
var result = loadResourceLocations.WaitForCompletion();
if (result.Count > 0)
{
string key = result[0].PrimaryKey;
Addressables.Release(loadResourceLocations);
return key;
}
Addressables.Release(loadResourceLocations);
return string.Empty;
}
}