Search Unity

Changes on common AssetBundle prefab don't apply to dependent AssetBundles

Discussion in 'Asset Bundles' started by amendolathiago, Jul 20, 2018.

  1. amendolathiago

    amendolathiago

    Joined:
    Aug 29, 2014
    Posts:
    3
    We have multiple scenes in our project that will be stored in their respective asset bundles. They share some common prefabs and files (placed in a separated asset bundle) and they also have a huge amount of files used exclusively for each scene. Since our editor became slower over time due to the number of files in the project, we decided to split it into multiple smaller projects containing each individual scene and their dependences along with the shared "core" - the common prefabs, scripts and files.

    We managed to build and use the common and scene asset bundles using this project structure properly, but if we need to update one of the common prefabs, we must rebuild not only the common asset bundle but all other scene bundles.

    Any ideas on how we could change a common prefab without needing to rebuild all asset bundles of the full project?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Why do you need to rebuild the scenes as well ? Could you give an example for what kind of change is made and why does it mean that a rebuild of everything is necessary ?
     
  3. amendolathiago

    amendolathiago

    Joined:
    Aug 29, 2014
    Posts:
    3
    In our case, we have changed the texture and layout of a menu prefab contained in our common asset bundle and rebuilt it. When I test the common bundle alongside the scene bundles by loading and opening a scene, I stumble into the old version menu. To fix this, I have to rebuild each scene bundle for the prefab changes to appear properly.

    Any thoughts about this behaviour?
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    How are you referencing that common prefab from other scenes? how do you know that it's not included twice? (once saved directly into the scene that uses it, once in the asset bundle)
     
  5. amendolathiago

    amendolathiago

    Joined:
    Aug 29, 2014
    Posts:
    3
    I placed an instance of this common prefab in each scene manually. Since the prefab instance is still connected to prefab file (its name appears in blue in Hierarchy tab) and the prefab file appears as a dependence of the scene bundle in the AssetBundle Browser, any changes applied to the common prefab shouldn't change the prefab inside the scene?
     
  6. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Prefabs are special in that while in the editor, the scene treats prefabs as a reference to the asset, however the player does not have this logic. So the prefabs are baked into the scene files directly as part of the build process, breaking any links to the prefab asset itself.
     
    Kichang-Kim and liortal like this.
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Interesting. So, at runtime, is there any difference at all between 2 scenes that have the exact same structure, but one of those hierarchies contains prefabs?
     
  8. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    The order in which we serialize the objects to disk could be slightly different as there is a lot that goes into that "layout" process. Outside of that though, nope, they basically are identical as a prefab is basically a "chunk" of a scene's hierarchy.
     
    liortal likes this.
  9. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    What about materials? I noticed that a scene assetbundle does not show any materials it uses in the manifest. I'm guessing it's just included in the scene assetbundle. But So when I add the material that the scene uses, into a different assetBundle, will the scene know to use that material in the separate assetBundle or is there now a duplicate material. One in the non-scene assetbundle and one embedded in the scene assetbundle?

    Thanks
     
  10. EugenAxenoi

    EugenAxenoi

    Joined:
    Dec 12, 2012
    Posts:
    2
    It looks like this logic of baked prefabs into scenes is the same for nested prefabs.