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

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:
    325
    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:
    559
    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:
    325
    Yes, that's the problem. Thank you.

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