Hi, is the following a bug or intentional?
when i change targets and the new target has the same name as the old one, the portrait does not update. (not all npc's with the same name have the same portrait)
basically, the easiest way to get it working is in the element change:
Code:
local Update = function(self, event, unit)
if(not UnitIsUnit(self.unit, unit)) then return end
if(self.PreUpdatePortrait) then self:PreUpdatePortrait(event, unit) end
local portrait = self.Portrait
if(portrait:IsObjectType'Model') then
local name = UnitName(unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
portrait:SetModelScale(4.25)
portrait:SetPosition(0, 0, -1.5)
portrait:SetModel"Interface\\Buttons\\talktomequestionmark.mdx"
elseif(portrait.name ~= name or event == 'UNIT_MODEL_CHANGED') then
local alpha = portrait:GetAlpha()
portrait:SetUnit(unit)
portrait:SetCamera(0)
portrait:SetAlpha(alpha)
portrait.name = name
else
portrait:SetCamera(0)
end
else
SetPortraitTexture(portrait, unit)
end
if(self.PostUpdatePortrait) then
return self:PostUpdatePortrait(event, unit)
end
end
to:
Code:
local Update = function(self, event, unit)
if(not UnitIsUnit(self.unit, unit)) then return end
if(self.PreUpdatePortrait) then self:PreUpdatePortrait(event, unit) end
local portrait = self.Portrait
if(portrait:IsObjectType'Model') then
local name = UnitName(unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
portrait:SetModelScale(4.25)
portrait:SetPosition(0, 0, -1.5)
portrait:SetModel"Interface\\Buttons\\talktomequestionmark.mdx"
else
local alpha = portrait:GetAlpha()
portrait:SetUnit(unit)
portrait:SetCamera(0)
portrait:SetAlpha(alpha)
end
else
SetPortraitTexture(portrait, unit)
end
if(self.PostUpdatePortrait) then
return self:PostUpdatePortrait(event, unit)
end
end
but i don't like the change to be in ouf so i've handled it in the layout.