Hello. Many of the addressable samples and demos I’ve seen show how to update addressable assets with content from a remote CDN. However, in this case, the game must be restarted to get the updated assets.
Is it possible to update addressable assets at runtime (i.e., no restart)? If so, how?
I have tried a few different approaches that use Addressables.CheckForCatalogUpdates and Addressables.UpdateCatalogs
And then I call something like newTexture.LoadAssetAsync where newTexture is an AssetReferenceTexture. Then, I change the mainTexture on the material for my mesh.
I’ve also tried an approach that first calls Addressables.LoadResourceLocationsAsync to get a list of IResourceLocations. Then I iterate over each location, and call Addressables.LoadAssetAsync Then, I change the mainTexture on the material for my mesh.
So, I build my app without any ABs (if you also, make sure you have cleaned your addressable ABs before, as they elsewise would be copied into your applications data folder), then build the ABs and upload ABs and catalogue to the CDN.
Then I call Addressables.UpdateCatalogs to get the latest catalogue from the CDN and call Addressables.LoadAssetAsync(textureIdentifier) and put that result into my texture. I’m not using AssetReference actually, but it works for me.
I changed a few lines of code to line up with what you’re doing, and I still cannot update the texture (or material) at runtime. I’ll keep trying a few more variations in code. Or maybe something is wrong with my Addressables settings.
Question: When you say “textureIdentifier” above, do you mean a hard coded string that points to your texture (e.g., Assets/Textures/newTexture.png)? Or do you get the IResourceLocatorfrom the catalogs returned from Addressables.UpdateCatalogs?
For anyone attempting to update assets at runtime using the Addressables system, I’ve figured out (with some help) how to do it with textures and materials. Here are the recommended steps:
Load mesh (Addressables or not), get access to material
newTexture.LoadAssetAsync - set this as mainTexture on material for mesh (newTexture is an AssetReferenceTexture).
Addressables.CheckForCatalogUpdates
If no updates, done. If updates, proceed
newTexture.ReleaseAsset - will give the mesh a pink texture, so ideally you’ve also hidden or disabled this mesh
Addressables.UpdateCatalogs
Get access to material again (listing this step in case reloading is required)
newTexture.LoadAssetAsync - set this as mainTexture on material for mesh
This process should work for reloading a texture via Addressables and swapping Renderer.sharedMaterial.mainTexture reference at runtime. It works with either AssetReferenceTexture.LoadAssetAsync or Addressables.LoadAssetAsync(“name”) workflows.