Importing an FBX with multiple meshes with the same name?

Hi everyone,

I am importing an FBX file hardware.fbx which contains 15 screws and 30 nails.

I have several other FBX files where my screws and nails are in different positions. Some examples of these are hardware@alphaConfiguration.fbx, hardware@betaConfiguration.fbx, and hardware@charlieConfiguration.fbx.

I have put the content of hardware.fbx in the scene as a gameObject called hardware. Occasionally I tell the hardware gameObject to go to an animation state of one of those configuration fbx’s clip.

I notice that all of the screws and nails in my FBX are not simply named “screw” or “nail” anymore, but rather “Screw 01”, “Screw 02”, “Nail 01”, “Nail 02”, etc. This does not cause a problem yet.

However, my UI displays the model number of the screw when I have the screw selected and the model number of the nail when I have the nail selected. It does this by passing the names of my hardware gameObject and its children to a database, which fetches the appropriate information for “nail” or “screw”.

This is broken. I cannot have “Screw 01” or “Screw 02” in my scene because they do not have an associated database entry. I’ll have to rename every screw in my scene back to “screw” and every nail back to “nail” manually. But will this break my animation system?

  • The obvious and easy solution would
    be to just tell Unity to not rename
    meshes on import. Unity should not be
    appending anything to “nail” or
    “screw”. There are multiples of them,
    and they are supposed to have the
    same name.
  • The second solution would be to manually (or via script) rename objects in the scene back to “nail” or “screw”, but I do not know if this will break my animation system.
  • The third solution would be to change my database query to ignore appended auto-increment text, but I don’t know how to do that without risking occasionally ripping the number off the end of something that was genuinely meant to have a number.

Instead of passing an array of characters, you could just check the first char:

string name=XXXX;

char check= name[0];