So I have this game project I’m working on for fun and it is fun!
My materials are very messy. I have linked materials in from other files, made materials in the main file, named my materials stupid names, “f” saved my materials when I didn’t really want or use them, used materials from several directories.
Now I’m cleaning house. I have all the textures nested in one directory, I have removed some duplicates and named the one’s I like with good names, but I have all these mystery materials and I don’t know what object they are attached to.
Is there a way to figure out which objects a given material is on?
Also in the outliner it is possible to choose Blender File as display mode and then go through the materials there. If you rightclick on a material and choose Select Linked it selects the objects that have the material.
You can also check it with python relatively easily:
import bpy
for every_material in bpy.data.materials:
result = ''
for every_object in bpy.context.scene.objects:
for every_slot in every_object.material_slots:
try:
if every_material.name == every_slot.name:
result += '
' + every_object.name
except:
pass
print(every_material.name + ' is assigned to:' + result if result
else every_material.name + ' is not used in this scene.')
I have created some buildings and they are in their own files. then I linked these buildings to another file to make cities. Then I linked the city file to the main file to create the world. So… if I have a brick wall material that is used for several buildings, I end up with several materials in the final “world file”.
ie.
building.blend 1 wallmaterial with texture from /texture
building2.blend 1 wallmaterial with the same texture form /texture
city.blend 20 wallmaterial I guess copies of the texture from /texture
world.blend 100 wallmaterial(can’t be good for performance)
I would like to combine these so blender only loads one copy of the material, not several and uses it on all the linked objects. Should I make them local and apply materials to whatever is broken? If I do and start messing with the materials, what will happen to the city and building files? I would like to reserve the right to edit them separately in the future.