Is there a way to query if a texture is available?
Do you know a way to query if a special texture (specified by a texture path) is available or not?
I'm almost sure that it is not possible. But ... well ... you never know ... ;) Thank you. |
I think that :SetTexture returns true if the texture was found. It returns true under some circumstances, at least. Not 100% sure that it's that.
|
Quote:
[e] SetTexture("") returns nil. Whatever this is good for. ;) |
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:
|
That's a very clever workaround Semlar. :)
|
Wow. That's a fantastic idea. Thanks a lot sir. :)
|
This method still works however the size is 1x1 pixel now. Which is a lot better since a proper texture can't be this size. So:
Lua Code:
|
Method I'm using in 9.0.2
Lua Code:
|
All times are GMT -6. The time now is 10:55 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI