Search Unity

Bug Is this a bug, or is it simply impossible to unpack a prefab variant only?

Discussion in 'Editor & General Support' started by Avalin, May 21, 2023.

  1. Avalin

    Avalin

    Joined:
    Oct 12, 2018
    Posts:
    98
    I am trying to unpack a prefab variant in editor code.

    I've been using PrefabUtility.UnpackPrefabInstance() and having it set to only unpack outermost root.
    This should leave me with the Prefab rather than the prefab variant, and it *looks* like it does, but it doesn't

    Now when I want to save this unpacked prefab back to a new variant... it does not acknowledge it was ever a prefab to begin with, despite the fact that it looks like one in the editor...

    My main issue is I am making an editor in which I want to modify Prefab Variants, such as deleting objects I've added to it...
    Turns out Object.DestroyImmediate doesnt work for that even with allowDestroyingAssets set to true... Hence I am trying to unpack to have just the prefab. If just either would work it would be awesome, but it seems like I hit a wall of limitations here?
     
    Last edited: May 21, 2023