Search Unity

ContentPipeline.BuildAssetBundles() does not correctly return dependencies related to scene

Discussion in 'Addressables' started by Kichang-Kim, Oct 18, 2018.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    Hi. I tested ContentPipeline.BuildAssetBundles() to migrate my old asset system and found that it doesn't return correct dependency information.

    My setting is here:

    assetbundle "prefab1"
    └ prefab1.prefab
    assetbundle "prefab2"
    └ prefab2.prefab
    assetbundle "prefab3"
    └ prefab3.prefab
    assetbundle "scene1"
    └ scene1.unity
    assetbundle "scene2"
    └ scene2.unity

    Then actual dependencies are here:

    prefab1.prefab depend on prefab3.prefab
    scene1.unity depend on prefab1.prefab
    scene2.unity depend on prefab2.prefab

    But ContentPipeline.BuildAssetBundles() return dependencies only "prefab1 depend on prefab3", there is no dependencies about scenes.

    I got correct results via old BuildPipeline.BuildAssetBundles() using exactly same AssetBundles[] parameters.

    (I tested using com.unity.scriptablebuildpipeline@1.0.1-preview, Unity 2018.2.6f1)

    Edit1:
    prefab1~3 is just cube object which is created by GameObject>3D Object>Cube. I found that other types of dependency (lightmap, reflection probe, occlusion culling and so on) are correctly obtained. It seems that ContentPipeline can't search prefab-scene dependencies.
     
    Last edited: Oct 18, 2018
  2. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    is your prefab directly in the scene (i.e. blue) or just referenced by a script that does
    Instantiate()
    ?
    in the first case, the prefab is embedded into the scene at build time and the old behaviour is wrong (dependency is actually not needed)

    also, how does your prefab1 depend on prefab3? if it's nested, the dependency is wrong because it gets flattened at build time
     
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    @M_R
    1. In my case, prefab is directly in the scene (as you say, it's name shown as blue). Do you mean that I can't separate prefab asset from the scene assetbundle? it seems to be inconvenient... (small changes for single prefab affects all scene assetbundles which using that prefab)

    2. prefab1 depend on prefab3 by using monobehavior script which has public GameObject field.
     
  4. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    then it's expected. the scene gets flattened during build, prefabs don't exist at runtime. the only way to keep them separate is via Object references and
    Instantiate()
    . (same for nested/variant prefabs).
    if old system says there is a dependency, it's wrong (you can test by actually changing the prefab in the bundle and see that the old scene bundle still uses the old version)
     
  5. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    @M_R
    Thanks for detailed reply. I'll re-construct my project to consider this behaviour.