Search Unity

Direct dependencies of prefab variant differs from that of the original prefab

Discussion in 'Prefabs' started by prg-liulie, Jul 5, 2019.

  1. prg-liulie

    prg-liulie

    Joined:
    Dec 23, 2017
    Posts:
    7
    Use AssetDatabase.GetDependencies(prefabVariant, false) to get direct dependencies of a prefab variant, and the result is different from that of the original prefab when there are nested prefabs in the original prefab. It seems that the prefab variant doesn't depend on the nested prefabs directly, but depends on the dependencies of the nested prefabs directly. Is this a bug?
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,487
    Moved the thread since it doesn't seem to be specific to 2019.3.
     
  3. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,594
    I can't say for sure if it's a bug, and the rest of my team are on vacation. But I'm not sure it's necessarily a bug.

    In terms of the file itself, the Prefab Variant only contains an instance of the Prefab Base, as well as any overrides. It doesn't know about nested Prefabs in the base, so it makes sense that these are not direct dependencies.

    When you say the Prefab Variant depends on the dependencies of the nested Prefabs directly, which dependencies are those? If it's further nested Prefabs I'd be rather surprised. But if it's things like materials or meshes - basically anything referenced through an Object Field in some component - these might be handled in a different way compared to how Prefabs that contain other Prefabs are handled, that cause these dependencies to be "inherited" by outer Prefabs and Prefab Variants. I'll need to have someone else confirm this though.
     
  4. prg-liulie

    prg-liulie

    Joined:
    Dec 23, 2017
    Posts:
    7
    Thanks for your reply :) As you say, the dependencies are monobehaviours and materials, etc. Not nested Prefabs.