All components lost when changing parent in Blender

I notice that if I change any part of the parenting hierarchy, any components on the object(s) will be removed in Unity.

How can I attach components to an object, while still being able to reparent it in Blender? My scene is made up mostly of a cockpit, with a multi-level hierarchy. Any time I move a switch or a gauge from one panel to somewhere else, I lose the components in Unity. I would be happy to use unique object names if the components would simply remain attached to that object.

I am importing with FBX at the moment, but I see the same thing happening in a .blend asset.

Can someone please help me with this? Maybe suggest some way to work around it?

NEVER rename items in Blender after you have imported into Unity, because then Unity imports them as though they were new GameObjects. That's how the mapping works if you look in the .meta file associated with your Blender file. It is done by name.

I would also NEVER reparent them because of the root (-90,0,0) rotation issue when going from Blender's right-hand system to Unity's left-hand system. Reparenting potentially moves an object in or out of the guard area for this rotation.

The best way to do this is to make all the elements of your cockpit in the Blender file (or separate Blender files if you wish).

Then build your prefab (or scene) containing the cockpit, and explicitly do all the parenting and organizing ONLY in Unity, just using the Blender file as a list of "chunks of geometry" to use. I'm talking about actually dragging specific meshes out of your Blender file and connecting them in your scene / prefab.

I also like to keep making fresh copies of the Blender file for each major change I do, and then connect up the new mesh in the prefab.

I am not renaming my objects. I am changing some part of the parenting structure. I’ve rarely seen any issues with the rotations.

I don’t think I can work without parenting objects in blender, it seems incredibly shortsighted to me that I can’t do this.

I’ll give a look at the meta file, thanks, I hadnt thought of that as I’ve been using fbx for a while now. Perhaps there’s some way to manually write changes to the meta. I can easily have unique object names, if only I could get unity to understand that (my guess was it took the names of all the parents in the hierarchy concatenated together as the thing to attach to.

You should think of it like a full path. If I tell you a file is in c:\work\foo.txt and I move it to c:\play\foo.txt, I haven't technically "renamed" the file, but you're not gonna find it from the first URI.

I do not see anything in the .meta file. Where does Unity store this map of paths and components?

Building on the above, I took a look around and compared a set of three "peered" objects vs a set of "parented" objects and how the meta file names the stuff internally. tl;dr "it's complicated."

7445552--912941--Screen Shot 2021-08-24 at 10.27.32 AM.jpg

Odd, my blend file has literally hundreds of objects, and the meta is just 100 lines long with no sign of any object names.

As a workaround, I am thinking I could maintain unique object names in blender, and the import the lot. I could then have a script in unity which adds the components, either something I trigger manually on an import, or in Start. Is there a way to make an array of objectnames and components show up in the inspector, and have the inspector for the component shown? That way I could add a new array element, and in it, add the object name and component and then component values.

I'm kinda desperate for some ideas here

It's already there. Select the blender file, open its children right in the project window. There are all your meshes. Drag the one(s) you want into the MeshFilters within your prefab or scene as you build it all up.

A year later and time for an update. I eventually just went with having unique names in blender (which is enforced by blender), and then after importing into unity, I run a script where it traverses the old object hierarchy and for each game object it finds, it searches the new hierarchy for the same-named object and then copies all the components over. It only takes a few seconds on a hierarchy with several hundred objects in it. I also added options to copy the static flag and the object layer from the old to the new. For an encore, it has a list of object names and a prefab to attach to it. I then save the new hierarchy as an update to the old prefab. This is working great for me, but I think it should have been a Unity feature from the start.