View Single Post
03-02-14, 07:47 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The simplest solution is probably going to be to hook the function that sets the text:

Code:
hooksecurefunc("UnitFrame_Update", function(self)
	if not self.name then return end

	if UnitIsPlayer(self.unit) then
		-- Color by class:
		local _, class = UnitClass(self.unit)
		local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
		self.name:SetTextColor(color.r, color.g, color.b)
	else
		-- Not a player. Return to default color:
		self.name:SetTextColor(1, 0.82, 0)
	end
end)
Feel free to color non-players by reaction instead of using the default color.

If you wanted to color pets by their owner's class, the simplest solution would probably be to look at the pet's creature type and just make an assumption -- eg. beast = hunter, demon = warlock, etc.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote