Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Addressables not handling prefab variants?

Discussion in 'Addressables' started by jonagill_rr, Sep 13, 2019.

  1. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    We noticed that we get an error when attempting to instantiate a prefab variant from a group marked to Pack Separately. The base prefab is in the same group, but since they are packing separately, the base prefab is not getting loaded as a dependency when we try to instantiate the prefab variant.



    Exception encountered in operation Instance<InstanceProvider>(Resource<GameObject>(TestObject Variant.prefab): Dependency operation failed with System.Exception.


    If I manually load the base prefab before attempting to instantiate the variant, it instantiates just fine.


    Prefabs that contain another asset bundled prefab nested inside them seem to fail similarly, although the error is different. They complain that the path to the prefab's bundle is invalid, even though it definitely exists in the Streaming Assets folder.


    Exception encountered in operation Resource<IAssetBundleResource>(nestedprefab.prefab_f14b9602375de526961ef704004adeaf.bundle): Invalid path in AssetBundleProvider: 'StreamingAssets/aa/Windows/StandaloneWindows64/packedassets_assets_assets/loadableassets/nestedprefab.prefab_f14b9602375de526961ef704004adeaf.bundle'.



    How much support should we be expecting for nested prefabs and prefab variants in Addressables right now?
     
    RecursiveFrog likes this.
  2. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    At runtime there is no concept of prefabs and their inheretence. All prefabs just become GameObjects. So I do not think there should be some problem with nested prefabs unless there is a bug.
     
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Please file a bug against unity and put the case number here. As already stated the prefabs should be flattened. What I'm guessing is that the base prefab is dependent on something else (say a material), then during the building/flattening we're missing that dependency link. Something like that. Regardless, since these things should just work, having your repro project would be a huge help.
     
  4. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    I've filed a bug against Unity containing the repro, but I haven't received a case number yet. While I wait to receive that, here is a zipped up copy of the repro project.

    It's simple to reproduce -- the test scene is set to try and instantiate the variant prefab, and you can verify that it loads successfully in all three play modes in editor. However, once you've built bundles and try to run it via a built player, you can see that it does not load the variant in the built player. If you change the Loader component's Object to Load field to load the base TestObject before it instantiates the variant and the rebuild, you can see that the built player is able to successfully instantiates the variant.

    I was hoping this was just an issue with the older version of Unity that we're running, but I just verified that it reproduces with the latest releases of 2018.4 and 2019.2
     

    Attached Files:

  5. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Any update on this?
     
  6. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    I believe the bug was closed out as no repro. I was unable to reproduce it again either after the fact, which was disconcerting.