View Single Post
04-21-18, 04:23 PM   #1
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
3D portrait background color not refreshing

Have little trouble with 3D portrait for my party frames. Not all party units get the background colored after i joined a group, i think there is need for some delay before it fires...

The code itself working great. If i /reload all background are colored. Can you correct it please?

-- 3D Portrait with classification/reaction backdrop color

local portrait = CreateFrame("PlayerModel", nil, self)
portrait:SetScript("OnShow", function(self) self:SetCamera(0) end)
portrait:SetSize(66, 66)

table.insert(self.__elements, function(self, _, unit)
if (unit == 'party1') or (unit == 'party2') or (unit == 'party3') or (unit == 'party4') then
portrait:SetPoint("CENTER", self, "CENTER", -44, 2)
end
end)

portrait:SetFrameStrata("BACKGROUND")
portrait:SetFrameLevel(14)
portrait.type = "3D"

local bg = portrait:CreateTexture(nil, 'BACKGROUND')
bg:SetTexture(m.textures.portrait_backdrop)
table.insert(self.__elements, function(self, _, unit)
local color
if UnitIsPlayer(unit) then
local _, class = UnitClass(unit)

if ( class and RAID_CLASS_COLORS[class] ) then
color = RAID_CLASS_COLORS[class];
end
else
local reaction = UnitReaction(unit, "player");
if ( reaction ) then
color = FACTION_BAR_COLORS[reaction]
end
end

if not color then
color = { r=1, g=1, b=1, a=1 }
end

bg:SetVertexColor(color.r, color.g, color.b)
end)
bg:SetAllPoints()
local overlay = CreateFrame('Frame', nil, portrait)
overlay:SetPoint('TOPLEFT', -1, 1)
overlay:SetPoint('BOTTOMRIGHT', 1, -1)
overlay:SetBackdrop(m.temp.temp2)
overlay:SetBackdropColor(0, 0, 0, 0)
overlay:SetBackdropBorderColor(0, 0, 0, 0)
self.Overlay = overlay

local shader = overlay:CreateTexture(nil, 'BACKGROUND')
shader:SetTexture(m.textures.temp3)
shader:SetVertexColor(0, 0, 0, 0.75)




self.Portrait = portrait
  Reply With Quote