From 4e0610afaf43af8dd85654584fa2b27fb3e12ba7 Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 4 Nov 2019 09:33:39 +0100 Subject: [PATCH] unitframes: delay portrait updates to first frame --- api/unitframes.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 77f2819f..1dc79ae0 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -730,6 +730,14 @@ function pfUI.uf.OnUpdate() pfUI.uf:RefreshUnitAnimation(this) + -- update portrait on first visible frame + if this.portrait and this.portrait.model and this.portrait.model.update then + this.portrait.model.lastUnit = UnitName(this.portrait.model.update) + this.portrait.model:SetUnit(this.portrait.model.update) + this.portrait.model:SetCamera(0) + this.portrait.model.update = nil + end + -- trigger eventless actions (online/offline/range) if not this.lastTick then this.lastTick = GetTime() + (this.tick or .2) end if this.lastTick and this.lastTick < GetTime() then @@ -1496,13 +1504,10 @@ function pfUI.uf:RefreshUnit(unit, component) if unit.tick then unit.portrait.model.next:SetUnit(unitstr) if unit.portrait.model.lastUnit ~= UnitName(unitstr) or unit.portrait.model:GetModel() ~= unit.portrait.model.next:GetModel() then - unit.portrait.model:SetUnit(unitstr) - unit.portrait.model.lastUnit = UnitName(unitstr) - unit.portrait.model:SetCamera(0) + unit.portrait.model.update = unitstr end else - unit.portrait.model:SetUnit(unitstr) - unit.portrait.model:SetCamera(0) + unit.portrait.model.update = unitstr end end end