Posted by bilalakil on Sat, 16 Jul 2011 13:46:41
I've noticed that whenever I make a texture, of any simplicity, it will not appear at all unless I make it inherit something. For instance:
local shadowBar = CreateFrame("Frame", nil, UIParent) shadowBar:SetSize(300, 24) shadowBar:SetPoint("CENTER", 0, -96) local texture = shadowBar:CreateTexture() texture:SetTexture(0, 0, 0, 0.3)
doesn't show anything, however if I put anything at all for the texture to inherit - EVEN A BUTTON, it shows fine:
local shadowBar = CreateFrame("Frame", nil, UIParent) shadowBar:SetSize(300, 24) shadowBar:SetPoint("CENTER", 0, -96) local texture = shadowBar:CreateTexture(nil, nil, "ActionBarButtonTemplate") texture:SetTexture(0, 0, 0, 0.3)
I've been living with this strangeness for a long time, however now I'd like to find out why it's happening and possibly fix it, with your help if you can do so.
Posted by jnwhiteh on Sat, 16 Jul 2011 22:21:41
That's because you aren't giving the texture a size or a placement. It is treated the same as a frame, you have to place it somewhere on the screen for it to be visible. The reason the template works is because it has a default size/anchor, basically.
The easiest way to do this is something like this:
-- make the texture the same size as the parent frame by -- anchoring all points (TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT, etc.) -- to that frame. You can leave out the argument, and it will anchor to -- whichever frame it belongs. texture:SetAllPointa(shadowBar)
Posted by bilalakil on Sun, 17 Jul 2011 00:22:42
Oh sorry, I forgot to include that (it was somewhere else in the script). In cases that I include the size and everything, it still doesn't show. When everything is seemingly perfect but the texture doesn't inherit anything, it doesn't show, and then when I change only 1 thing - the texture's inherit, it does show. Yeah the size actually was on my script, just not the example one, so I still have the same problem.
Posted by jnwhiteh on Sun, 17 Jul 2011 08:47:37
Size and placement (i.e. anchor points). You do not, absolutely do NOT need to inherit a texture to make it work. You're doing something wrong with your code if that is the case, but you have not posted a minimal NOT working example, so I cannot comment on that..