Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Does variants work with prefabs in scene?

Discussion in 'Asset Bundles' started by Maeslezo, Jan 21, 2019.

  1. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    89
    Summary:
    I have a scene in a bundle. The scene has a prefab. The prefab is in other bundle, with two variants.
    The scene always load the same prefab, regardless of the variant

    Does variants work with prefabs in scene?

    Additional Info
    The scene has four prefabs:
    Prefab 1: Variant a and b only differ in the texture. It works
    Prefab 2: Variant a and b only differ in the material. It works.
    Prefab 3: Variant a and b are totally different prefabs. It is loaded and instantiated in runtime. It works
    Prefab 4: Variant a and b are totally different prefabs. Prefab is in scene when the scene is loaded

    Thank you

    scene bundle.png
    variant bundle.png Result.png
     
  2. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    394
    when you build, any prefab in the scene is unpacked ("baked" as plain gameObjects). prefabs don't exist at runtime.
    if you want variants (or just being in a different bundle), you need to instantiate dynamically
     
    Maeslezo likes this.
  3. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    89
    Yes, that's the problem. Thank you.

    upload_2019-1-21_16-42-15.png