This should work in place of replacing
GetUnitName(). It should still cover the stock UnitFrames along with the AchievementUI, InspectUI, and TradeFrame.
Lua Code:
local function UpdateNameText(fontstring,unit) if fontstring and unit and UnitIsPlayer(unit) then fontstring:SetText((UnitName(unit))); end end
EventUtil.ContinueOnAddOnLoaded("Blizzard_AchievementUI",function()
hooksecurefunc("AchievementFrameComparison_SetUnit",function(unit) UpdateNameText(AchievementFrameComparisonHeaderName,unit); end);
end);
EventUtil.ContinueOnAddOnLoaded("Blizzard_InspectUI",function()
InspectFrame:HookScript("OnEvent",function(self,event,unit)
if event=="UNIT_NAME_UPDATE" and unit==self.unit then self:SetTitle((UnitName(unit))); end
end);
InspectFrame:HookScript("OnShow",function(self)
if self.unit then self:SetTitle((UnitName(self.unit))); end
end);
end);
EventUtil.ContinueOnAddOnLoaded("Blizzard_UIPanels_Game",function()
hooksecurefunc("TradeFrame_Update",function(self)
UpdateNameText(TradeFramePlayerNameText,"player");
UpdateNameText(TradeFrameRecipientNameText,"NPC");
end);
end);
EventUtil.ContinueOnAddOnLoaded("Blizzard_UnitFrame",function()
local function _UnitFrame_OnEvent(self,event,unit)
if event=="UNIT_NAME_UPDATE" and unit==self.unit then UpdateNameText(self.name,unit); end
end
hooksecurefunc("UnitFrame_Update",function(self) UpdateNameText(self.name,self.overrideName or self.unit); end);
hooksecurefunc("UnitFrame_OnEvent",_UnitFrame_OnEvent);
for _,frame in ipairs{TargetFrame.totFrame,FocusFrame.totFrame} do
frame:HookScript("OnEvent",_UnitFrame_OnEvent);
end
local function StealthedArenaUnitFrameMixin_UpdateName(self,unitclassinfo)
UpdateNameText(self.NameText,self.unitFrame and self.unitFrame.unitToken);
end
hooksecurefunc(StealthedArenaUnitFrameMixin,"UpdateName",StealthedArenaUnitFrameMixin_UpdateName);
if CompactArenaFrame then
for i in ipairs(CompactArenaFrame.memberUnitFrames) do
hooksecurefunc(CompactArenaFrame["StealthedUnitFrame"..i],"UpdateName",StealthedArenaUnitFrameMixin_UpdateName);
end
end
hooksecurefunc("CompactUnitFrame_UpdateName",function(self) if self.name:IsShown() then UpdateNameText(self.name,self.unit); end end);
end);