I think when they introduced the streaming client they broke SetTexture's ability to determine if a texture exists.

Anyway, I developed a way to do this a while back for a map project I was working on. As long as the dimensions of the texture you're checking aren't 8x8 you can use it.

It works by taking advantage of the fact that setting a texture's size to 0 causes it to default to the real texture's actual dimensions, if it fails to load the texture then it falls back on the green "missing" texture which seems to be 8x8.

If you need to check a lot of textures at once you'll need to make some sort of queue since textures take time to load if they aren't cached. You can use an OnUpdate script or frames with OnSizeChanged scripts, whatever's more convenient for your situation.

Lua Code:

function TestTexture()

local f = CreateFrame('frame')-- Don't create a new frame for every texture, this is just an example

local tx = f:CreateTexture()

tx:SetPoint('CENTER', WorldFrame)-- The texture has to be "visible", but not necessarily on-screen (you can also set its alpha to 0)

f:SetAllPoints(tx)

f:SetScript('OnSizeChanged', function(self, width, height)

local size =format('%.0f%.0f', width, height)-- The floating point numbers need to be rounded or checked like "width < 8.1 and width > 7.9"

if size =='88'then

print(tx:GetTexture(), "doesn't exist or can't be determined")

else

print(tx:GetTexture(), "exists")

end

end)

tx:SetTexture('interface/icons/inv_mushroom_11')

tx:SetSize(0,0)-- Size must be set after every SetTexture

end

Keep in mind if the texture gets parented to another frame its size is going to get scaled.