Is any way to located specific Asset by name or group in IResourceLocation?

I want to initialize my game by this way:

Load Custom Container Data File (like “ResourceContainer” which is ScriptableObject, and set “preload” tag) → Use Linq to remap AssetReference by its key → Load AssetReference if necessary

My Resource Container Class can put lot of AssetReference so I have to divided container by name or group.
However, when I used “Addressables.LoadResourceLocationsAsync” to get IResourceLocation, I don’t know how to search container file. Sounds like IResourceLocation does not apply way to query by its name or group.

public void LoadInitializeData() {
        var loader = Addressables.LoadResourceLocationsAsync(LOADING_INITIALIZE_TAG);
        loader.Completed += OnInitializeDataLoaded;
    }
    private void OnInitializeDataLoading() {
    }
    private void OnInitializeDataLoaded(AsyncOperationHandle<IList<IResourceLocation>> op) {
        if (op.Status == AsyncOperationStatus.Failed) {
            // Load Failure
            _initializeStatus = LoadingStatus.Failure;
        }
        var resourceLocations = new List<IResourceLocation>(op.Result);
        // I don't know how to query by name or group of AssetReference
     
    }

Is there any way to do?

The Resource Location only contains what is necessary to load the Object. Depending on your settings you may be able to identify what you want from the data.

InternalID indicates where to load the location. For bundles, this will be the file location or url. For assets in bundles, this will be the internal id of the the object in the bundle. This is defined by the “Internal Asset Naming Mode”. If you have this as full path for example, you can use this to reference the asset “Assets/etc/myPrefab.prefab”. This is however generally the best mode for development, with dynamic best to use for release to reduce the size. So you may not be able to use this.

You cannot query by Group without adding a label to each asset in the Group for the Group name. The group is only used in the editor which is used as a collection of asset to be built in a similar way depending on the group schemas.

The location does not contain the keys other than primary key on how it is loadable. For this you will need to check each key in the Locators to see if they contain the location. We only have a mapping of key to location for the loading. For what you need you will need to take the resource locators and create a mapping of location to keys.

1 Like