Search Unity

Question get the "prefab base" of a variant via code

Discussion in 'Prefabs' started by Marc-Saubion, May 1, 2021.

  1. Marc-Saubion

    Marc-Saubion

    Joined:
    Jul 6, 2011
    Posts:
    655
    Hi everyone.

    I'm working on an editor tool that will add a custom component on designated GameObjects, including applying the change to a prefab if necessary.

    It works fine except if the prefab is a variant. In this case, my script will apply the changes to the variant but not the original prefab it's based on.

    My script does the first option and I'm looking for the second.

    prefab_variant.png

    Doesn't anybody knows how to get the "prefab base" of a variant via code?

    I checked the PrefabUtility API but the documentation is very limited and I don't know what is the technical term for what I'm looking for.

    Thanks