Thread: GUI's
View Single Post
05-28-05, 03:18 PM   #29
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
sure thing! the SetTexture("texturepath"); function is pretty useful, in that you can change the texture associated with a texture object at will. This is most notable seen in modifications that allow toggle buttons. When you hit the button, and thereby "toggle" it on, or off, the texture can be set to change based on what that value is. I don't have time to go into the specifics right now, but I might be willing to start some discussion threads on it regarding the uses of it.

Basically if you have a texture called "MyTexture" you would do this:

MyTexture:SetTexture("Interface\\AddOns\\myAddon\\mytexture01.tga"); (as someone mentioned earlier, you can leave out the .tga here, as the engine sees the graphics file without the trailing file type, however I prefer to use the extension, for practicality sake, as well as the fact I have seen it not work a couple times...)

With some coding, you could do something like this:

Code:
function onToggle()
	if (myToggle) then 
		myToggle = false;
		myTexture:SetTexture("Interface\\AddOns\\myAddon\\ToggleOff.tga");
		-- do whatever the toggle is meant to "toggle" off
	else 
		myToggle = true;
		myTexture:SetTexture("Interface\\AddOns\myAddon\ToggleOn.tga");
		-- do whatever the toggle is meant to "toggle" on
	end
end
You can also use
MyTexture:SetTexCoord(minX, maxX, minY, maxY); so for people like Cairenn who was discussing having a single file with multiple elements, you can leave the texture as is, and just change the Texture Coordinates...
  Reply With Quote