#How can I get the Prefab Asset of a

1 messages · Page 1 of 1 (latest)

native marsh
#

I have used various combinations of PrefabUtility methods along with PrefabUtility.GetCorrespondingObjectFromSource and PrefabUtility.GetCorrespondingObjectFromOriginalSource in an attempt to get to the Prefab Asset and modify it but all attempts have thus far resulted various edge cases of missed Prefabs/Variants and/or Nested Prefabs/Variants giving me their Root Prefab Asset instead.

#

Context: I need to be able to strip a scene and all associated prefab instances of all non-Unity components so I can use the Unity Export Package option on the scene and get everything referenced minus project scripts and things referenced by those scripts.

haughty anvil
#

You could try a combination of PrefabUtilitie's GetNearestPrefabInstanceRoot and GetOutermostPrefabInstanceRoot, descending down the tree of objects, comparing Nearest and Outermost instance roots if they are the same. If they are not, it could mean you are checking inner prefab. From this you should be able to acquire prefab asset. This is an idea, I am not sure if this would work, but I don't see why it wouldn't. You would have to check yourself