Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How can you get at runtime the asset bundle file name a location is in?

Discussion in 'Addressables' started by Nemikolh, Jul 6, 2022.

  1. Nemikolh

    Nemikolh

    Joined:
    Sep 26, 2017
    Posts:
    1
    Hi,

    I'm trying to get the name of the asset bundle file a location is in. I have tried several things but all of them failed.

    From my understanding, when asking at runtime for a location, the Addressables system is able to figure out how to resolve it to an asset bundle file (or URL if it's a remote location). I just can't figure how to get that information from the API.

    So I have a group with an addressable asset in that group and I have assigned a label called "preload" to that asset. With the following code I then printed what info we get:

    Code (CSharp):
    1. var bundlesOp = Addressables.LoadResourceLocationsAsync(preloadLabel);
    2. yield return bundlesOp;
    3. foreach (var entry in bundlesOp.Result) {
    4.     Debug.LogFormat("Val: {0}", loc.PrimaryKey + " " + loc.ResourceType + " " + loc.InternalId + " " + loc.ProviderId + " " + loc.Data);
    5. }
    This print:

    Val: Prefab1 UnityEngine.GameObject UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider


    However, if I open the catalog.json file I can see that at the beginning of m_InternalIds array the name of the bundles are there. So the information is there. I just have no clue how to get it for a particular location.

    Anyone with a solution to this?
     
  2. slayter97

    slayter97

    Joined:
    May 31, 2023
    Posts:
    1
    I'm looking for the same type of information. Did you happen to resolve your issue?