I think the title pretty much sums it up, but when importing a model I ripped from a gamecube game into blender then importing that into unity, I end up with a model without textures. Apparently this is a known problem with importing from blender. Fortunately, from the original rip I also have a folder with all of the textures and when I import the model unity automatically creates empty grey materials that are already matched with their game objects. Unfrotunately, these materials are blank. But they do have the same name as the texture files. I could go in and assign each material to the texture of the same name by hand, but that’s a real pain with hundreds and hundreds of textures. Does anyone know of a good way to do this?
Yes, it’s pretty simple to do that. Editor scripts can find assets in the project directory and modify them. So you can use MenuItem to add a menu option to run your fix-up script, then in the method that is called, use the Selection class to get the selected asset(s), and for each one, check it’s a model, and then loop over its materials running whatever algorithm you need to find the textures (e.g. using AssetDatabase) and assign them to the materials used by the model.
You can also hook the whole thing up to an asset post-processor, so that whenever a blender file is imported it automatically runs this step afterwards. You may also be able to use one of the more specialized AssetPostProcessor overloads to do this more cleanly, e.g. OnAssignMaterialModel, which is responsible for finding the right material in the Unity scene to use for each material referenced by the imported model.