Search Unity

Question Question about Bundle dependencies on assets in Resources folders

Discussion in 'Asset Bundles' started by RandomUnityDev123, Oct 28, 2022.

  1. RandomUnityDev123

    RandomUnityDev123

    Joined:
    Oct 28, 2022
    Posts:
    16
    Hi, our game has asset bundles that has references to assets that also live in a 'Resources' folder. This means that those assets are being duplicated at runtime: once when game loads and once again when we load the bundle and instantiate whatever prefabs reference that asset.

    Shouldn't Unity be able to figure out that the contents going into a bundle are redundant if they're in a 'Resources' folder hierarchy? We're on Unity 2020.3 and soon to update 2021.3 but I don't see any new docs covering this. Unfortunately our game is very mature already so we can't switch to Addressables.

    Thanks in advance,
    Jeff
     
    jjmontes likes this.
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Content packed into an asset bundle cannot reference other assets from the game build. They've mentioned this in a few conference talks i've seen (and perhaps also some of the docs, need to check).

    You can try to work around this by packing the assets you stored under Resources into their own asset bundle, include this bundle in your StreamingAssets folder so it gets packed into your game build.

    Then Unity can establish a dependency relationship between the two bundles. This approach is somewhat limited since i don't think it covers all cases.
     
    RandomUnityDev123 likes this.