Anyone have tips on creating a new Catalog or IResourceLocation programatically at run time?
I’ve a large number of assets on a server with naming conventions.
I’d like to use Addressables for it’s load, instantiate, cache, counter, and memory-management.
Options I was thinking…
-
Craft an IResourceLocator and add to existing ResourceLocationMap at runtime?
-
Craft a catalog and use LoadContentCatalog.
Catalog is just an asset- How to create them?
Reverse engineer from Editor GUI or build scripts?
Would either of these approaches be appropriate? TIA
If you have a large number of assets, set them up in packs using addressables and selectively load the assets you need.
Loading the catalog doesn’t load the assets. Catalog is just a json file containing the asset keys and the path to the actual bundles, plus some base64 encoded stuff.
Do you really need to create a catalog at runtime? The only case I can think of needing any kind of catalog creation, would be if you created bundles at runtime, which isn’t possible as far as I know.
1 Like
I would go with a ResourceLocator, you can either use a ResourceLocationMap or create your own.
e.g. using an ResourceLocationMap
public void AddResourceLocations()
{
List<ResourceLocationData> locationData = new List<ResourceLocationData>();
locationData.Add(new ResourceLocationData(new string[] {"key"}, "c:/path/to/asset_bundle.asset", typeof(AssetBundleProvider), typeof(AssetBundle)});
var locMap = new ResourceLocationMap(locationData);
Addressables.ResourceLocators.Add(locMap);
}
2 Likes