- Home /
How to get original model prefab from an object a new prefab was created out of?
I'm working on a editor script working with prefabs in edit mode. My prefabs are mostly models with various things added here and there.
I need the functionality to remove empty game objects (no components or children) from the hierarchy of my object. If I compare children of my object with the bone array from the skinned mesh render on my object I don't get the expected results (bones with no weights get removed as well as they are missing from the bones array) as it seems to be pretty hard to differentiate the bones in the model's armature from regular game objects that might have been added in unity.
So what I thought about doing is just compare the hierarchy of the base prefab (which is the imported fbx model) with the one of the object in my scene and remove everything that was added to my object later and passes the criteria that way.
That works well but the issues comes when I create a new prefab out of the object in my scene as the prefab no longer points to the fbx model prefab so I can't compare the hierarchies this way anymore.
My question is, how can I get the prefab object of the original imported fbx if I've created a new prefab out of my object and it no longer points to the model but does to the new prefab?