Thread Tools Display Modes
11-15-10, 12:03 PM   #1
tenub
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 111
SetVertexColor Not Working

In kgPanels I have a panel with a striped texture. I can change the stripe color by messing with the background color slider. However, when I try to use the following code:

local _,class = UnitClass("target")
self.bg:SetVertexColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 1.0)

It does not change the stripe color. Any help?
  Reply With Quote
11-15-10, 12:06 PM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
You need to register target changes.

Code:
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, unit)
	if unit == "target" then
		local _, class = UnitClass("target")
		self.bg:SetVertexColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 1.0)
	end
end)
f:RegisterEvent("PLAYER_TARGET_CHANGED")

Last edited by Haleth : 11-15-10 at 12:09 PM.
  Reply With Quote
11-15-10, 01:41 PM   #3
tenub
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 111
Still doesn't work. I forgot to mention that my border color changes properly with the following:

local _,class = UnitClass("target")
self:SetBackdropBorderColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 0.25)

I just cannot figure out the texture background color. It seems like it should change but it just doesn't!
  Reply With Quote
11-15-10, 03:04 PM   #4
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
My guess is there's no object self.bg or it's not visible.

Try self:SetBackdropColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 1.0) instead.
  Reply With Quote
11-15-10, 04:27 PM   #5
tenub
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 111
No dice.

Edit: I tried changing the background to default solid and setting a fully opaque and white background color then using all forms of code to no avail. I even tried something as simple as "self.bg:SetBackdropColor(1.0, 0, 0, 1.0);".

Last edited by tenub : 11-15-10 at 04:32 PM.
  Reply With Quote
11-15-10, 04:33 PM   #6
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Good Lord ... if self.bg has no backdrop you cant set a color for it. If self.bg is not a texture you can't set a color for it.
If self:SetBackdropBorderColor works then self:SetBackdropColor will work also. Just try it.

Last edited by Duugu : 11-15-10 at 04:38 PM.
  Reply With Quote
11-15-10, 04:57 PM   #7
Beoko
Guest
Posts: n/a
Originally Posted by Haleth View Post
You need to register target changes.

Code:
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, unit)
    if unit == "target" then
        local _, class = UnitClass("target")
        self.bg:SetVertexColor(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 1.0)
    end
end)
f:RegisterEvent("PLAYER_TARGET_CHANGED")
PLAYER_TARGET_CHANGED doesn't provide an argument for unit since you're just changing targets. The code inside of the if statement will never fire.
  Reply With Quote
11-15-10, 05:00 PM   #8
tenub
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 111
I do understand. It has a backdrop is the thing and I tried your code among other things. I've tried everything. I just reloaded and half of my panels disappeared. I exited and relogged and reloaded my layout and 80% of my panels aren't there anymore. Guess I'll do a fresh install of kgPanels. Hooray...

Edit: works now, I guess kgPanels was getting too messy from my 5 or so different layouts and decided to take a poop.

Last edited by tenub : 11-15-10 at 06:18 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetVertexColor Not Working


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off