
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
28 lines
924 B
C#
28 lines
924 B
C#
using UnityEngine.AddressableAssets;
|
|
|
|
/// <summary>
|
|
/// A utility class for various Addressables functionality
|
|
/// </summary>
|
|
public static class AddressablesUtility
|
|
{
|
|
/// <summary>
|
|
/// Get the address of a given AssetReference.
|
|
/// </summary>
|
|
/// <param name="reference">The AssetReference you want to find the address of.</param>
|
|
/// <returns>The address of a given AssetReference.</returns>
|
|
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;
|
|
}
|
|
}
|