Rename Mesh -- editor script ?

When I imported .fbx or .obj exported from Blender (this might apply to other 3D modelling softwares), sometimes the mesh name is incorrect/different. For example, I have a mesh named circle_002, while in reality it is a partial arc that I edited from a circle, hence it keeps the name of the circle.

I do know that I should name my mesh/object before I export them, most of the time I make sure that I name them properly.

However, there are cases where it would be better to directly rename the mesh in Unity

  • 50-60+ meshes that happens to have very similar names
  • just want to rename the meshes for better organization purpose
  • poor/bad naming of the meshes makes them difficult to find when it is needed
  • I am just too lazy to rename/export/import it all over again
  • etc.

Do Unity have any button/key to do this? Or should I start looking at writing my own editor script?

Since the question got already bumped I’ll post an answer ^^.

I see two approaches to this issue. The main problem is that the imported assets from an fbx file are read-only sub assets of the model file. Technically you can simply change the name of the mesh asset. However whenever the model gets re-imported the name change would be lost.

The first approach I could think of is to create an AssetPostProcessor which stores an extra config asset alongside the model asset. There you could store your “rename rules”. So whenever the model is reimported the asset post processor should look up the config and apply the name changes during import. This approach has some issues. First how you make sure that “config” sticks to the actual asset when it might be moved around in the project. The next issue might be what the renaming data is composed of. If you just do a string to string translation it would break if the mesh is renamed in the original file. What might also work is to store a Mesh reference alongside the new name. As long as the meta file is not lost the mesh references should persist.

A slightly more robust and maybe simpler approach would be to simply copy / extract the mesh data as seperate “.asset” file. This would completely decouple the mesh data from it’s original model file. In that case the name would be kept. However since the mesh is essentially extracted from the original fbx import it does not “update” when the fbx file is updated. Actually you could completely delete the fbx file since the mesh would be a new standalone asset.

Both approaches have some advantages and some disadvantages. For the first approach it might work to store the renaming information in a hidden monobehaviour component which gets automatically added to the imported object. I have never tried if such data persists a reimport of the asset. If it doesn’t you probably want to use a ScriptableObject which is stored somewhere in the assets folder.

I’m not aware of any magic buttons that would be helpful, but an editor script can do the job. You could have it search for all mesh assets, make a nice way to display / select / edit them, and the sky’s the limit from there.

I’m not certain how you’d mark up your changes to avoid having the re-importing process reset mesh names to whatever they were in your 3d app, which could introduce the added hassle of keeping your edited assets as copies. As the answer to your question, yes, you can use editor scripting to accomplish this and more, but whether it’s worth your time is up to you. :wink: