Search Unity

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:
    33
    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:
    230
    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

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    978
    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:
    33
    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:

unityunity