Dependancies not being loaded properly after using DownloadDepenenciesAsync

Hi,

I am trying to setup bundles via Addressable assets. It is a requirement from Apple that we prompt users for additional asset downloads. So we are using the feature Addressables.GetDownloadSize() in order to get the total download size and prompt the user.

From there we are downloading Addressables.DownloadDependenciesAsync and passing a list of addresses to download.

That functionality is working great, I am able to successfully download the bundle. It is cached so the next time I start the game all seems to be working fine. Until…

When I get to the game scene and I instantiate my Addressable Asset

_handle = Addressables.InstantiateAsync(levelAsset, new InstantiationParameters(Vector3.zero, Quaternion.identity, null), true);
     _handle.Completed += OnInstantiatedComplete;

After the level is instantiated, the level shows below (Pink) in the editor and is not loaded correctly.

When I inspect one of the loaded assets, it tells me that the "Material does not have a _MainTex texture property, it is required for SpriteRenderer. However, I am using the Default Sprite Shader.

I am thinking this could be from one of two reasons, there is some bug that doesn’t process the shader correctly. Or, more likely, It can’t find the asset blocks_9 in the spritesheet “Blocks”.

I have tried a number of things to attempt to resolve this:

  1. I have had the asset as “built into the project”
  2. I have placed the assets (textures) in a Resources folder
  3. I have placed the assets in the bundle with the prefab.
  4. I have placed the assets in a new bundle group and loaded at the same time as the prefab.

None of these options work.

They way my assets are structure are as follows.

  1. I have a prefab called “AddressableLevel” this prefab is labeled and marked as addressable.
  2. I have now placed all the textures and materials in a new Group

I really need this to work, or understand the right way to make this work. My assumption, is that I can save a prefab with the configuration of and placement of my level, even if the assets are existing and built with with he project. Or in another scenario I should be able to put all the assets related for that level into a bundle group and download the prefab configuration & all the related level assets.

What am I doing wrong here?

TLDR: I failed to reproduce your issue. But I list what works for me below, you can check the differences. If you think it’s a bug, please fire a bug report (better with a minimal reproducible repo).

  1. There’re two shader related issues with sprite, but none of them similar to your issue.
    Internal shader error on Sprites-Default after loading twice
    Shader references disappear when released

  2. It seems an issue when mixing sprite sheet, custom material and shader. However I did a simple test it works for me.

The custom shader and mat has been packed into the bundle correct.

The loaded asset with custom mat and shader.
5086295--500876--upload_2019-10-20_11-41-10.png

  1. Then I moved the sprite and mat into another group just like you did. I don’t know the intention though.
    5086295--500885--upload_2019-10-20_11-59-14.png

The sprite and mat are packed correctly into a separate bundle.

The prefab bundle has a dependency reference to the support bundle.

It just loaded as the first test.

  1. I also moved the two groups to remote, also works.

are you in Packed Play Mode?

5086676--500960--upload_2019-10-20_3-2-7.png

When I run in Fast Mode & Virtual Mode it works fine.

Also, I am not using a custom shader. I am using the sprite/default shader.

I tested in the packed mode.

hi. did you release the handle on _handle.Completed += OnInstantiatedComplete; function?

I realized my materials are missing when I release the handle, so when I don’t release it, it works

1 Like

What version of Addressables are you using? I tried other built in shaders and am experiencing the same problem.
How are you downloading the assets? Are you using the DownloadDependenciesAsync?

Also note, I was using a Lightweight RP project. Could that be the issue?

Addressables 1.2.4

In my test,

  • I don’t call DownloadDependenciesAsync exclusively, but use LoadAssertAsync directly. DownloadDependenciesAsync is not relevant here, LoadAssertAsync will also fetch the remote assets if needed.
  • I don’t release the handle manually, leave it to the system. However if you load asset, then release handle while still use the asset on screen, it may cause issues like @cemleme described.
  • Not use LRP.

Update:

I tried to do the same thing in a repro project using just the bare minimum assets.

5087480--501140--upload_2019-10-20_10-40-3.png

5087480--501131--upload_2019-10-20_10-35-25.png

I tried this from both a LWRP project and a normal project. It is working in both my repro projects! I don’t understand why my other project is not working.

Any ideas on how to track the issue down in my existing project?

As you said it works in fast mode, implies it may a packing issue. Things to try out

  • Enable log in settings.
  • Disable cache (in group settings).
  • Or change to back to local bundle to avoid network issue.
  • Rebuild player content, then use Unity Asset Bundle Browser tool to inspect the bundle like I did in floor #2.
  • Run analyze see if anything stranges.

Just checking something (that might be obvious, but easy enough to trip up on): If you run another platform in the Editor (e.g. IOS) it won’t work in packed mode, because the packed assets have been prepared for IOS player only. That typically affects textures and shaders. Your other editor test cases may be set to the same architecture as your machines platform so they work.

1 Like

That might have been the problem @rg_johnokane , I’m not sure. I created a new project cleaned up a bunch of junk i wasn’t using and move all my code and assets into the new project and now it works. But I noticed that I have not switched to Android or iOS yet. So it is StandaloneOSX and it is working in that mode with Packed assets. So it very well could have been because I had not built the StandaloneOSX assests in my other project and was in the Android build mode.

I kind of feel like that should be a bug. Shouldn’t it look for the assets of your current build target? Seems weird that I wouldn’t be able to test this end to end from the Editor when building for mobile.

Same issue on iOS target platform. Any solution?