Deleting unwanted UV textures

Is there a way to delete unwanted UV textures (for example when i append a scene, many textures are duplicated, and i end up with texutres like Grass.jpg, Grass.001.jpg, Grass.002.jpg, and so on) Does this also affect the size of the game?. Help would be greatly appreciated

:wink: Hehe, I take another simple question. Hmm, I wish there was an easier way. Maybe there is.

Well for the unwanted textures you have to make sure they’re not used by any of the meshes in your .blend. Then just click on the name of the texture and delete the name. It’ll be blank, then change into some number with a 0 in front. Don’t be surprised that they don’t get deleted right away. Sometimes you have to open or save and open it a couple of times before the link to the texture gets deleted from the .blend file.

A little trick to see which meshes have the textures, just pack all the textures that you want to use into that .blend file. Copy it and paste it on your desktop. Open the .blend and only the textures that have packed textures should have a texture on them. The meshes that use the unwanted textures, (the ones without the packed textures) will show up pink. They just reassign textures and delete the unwanted ones…

Hope this helps. Hmm, if there’s an easier way, someone else please tell me too, I’d like to know.

Jason Lin

Thanks a million :wink:

I have the same issue, in crescent dawn we are dealing with a huge amount of textures. i wish it were as simple as “remove all instances of this texture”… I think we should post that as a feature request.

RonC

uhh, you pretty much did

and my response:
peculair, you can’t seem to assign None to a nmface.image

TypeError: expected image object

oh well, I guess you’re only going to get to replace images

#!BPY
"""
Name: 'Replace Images'
Blender: 233
Group: 'Object'
Tooltip: 'Replace an image in all selected objects with another'
"""
import Blender

"""
this script's goal is to delete an image from all selected objects

it probably could be rather trivially modified to replace that image with another
"""
images = []
for obj in Blender.Object.GetSelected():
	if obj.getType() != "Mesh": continue
	for face in obj.getData().faces:
		if images.count(face.image) == 0:
			images.append(face.image)

# prompt the user which image to delete
# I probably want to sort them....
def cmpfn(x,y):
	ax = x
	ay = y
	if not ax: ax = "~~~~None"
	else: ax = ax.name
	if not ay: ay = "~~~~None"
	else: ay = ay.name
	if ax < ay: return -1
	if ax == ay: return 0
	return 1
images.sort(cmpfn)

promptst = "Select Image to Replace%t"
for i in range(len(images)):
	if not images[i]:
		promptst += "|None%x"+str(i)
	else:
		promptst += "|" + images[i].name + "%x"+str(i)

choice = Blender.Draw.PupMenu(promptst,24)

srcimg = images[choice]
if choice != -1:
	# prompt user for image to replace with
	promptst = "Select Image to Replace With%t"
	
	images = Blender.Image.Get()
	images.sort(cmpfn)
	
	for i in range(len(images)):
		if not images[i]: # doubt this will be used
			promptst += "|None%x"+str(i)
		else:
			promptst += "|" + images[i].name + "%x"+str(i)
	
	choice = Blender.Draw.PupMenu(promptst,24)
	
	if choice != -1:
		destimg = images[choice]
		for obj in Blender.Object.GetSelected():
			if obj.getType() != "Mesh": continue
			mesh = obj.getData()
			for face in mesh.faces:
				if face.image == srcimg:
					face.image = destimg
			mesh.update()
		print "###replaced images successfully"

you’ll need to change the Blender.Draw.PupMenu lines if you have indeed so many images [becaue the menu will go off the side of the screen], and it appears you cannot delete an image.

so, if everything is selected this should do an adequate job of removing all refrences to an image

Another thing this avoid this problem: having unwanted textures in you blend file. If you model things for your game, try to model them in a seperated blender file, Then aftherwards when you get your hands on the Game Logic setup, append them from that blender file. Only the wanted things will be added. This is the way I work most of the time. Importing models, textures, ipo’s and armature/actions. Works great. :stuck_out_tongue:

That’s simply not a good idea at least in my case with crescent dawn, where all the models are more or less modelled around the landscape or everything else. Even aesthetics need to be calculated as I model… So that idea is for the “trash heap” in my case.

RonC