Here's the same overall code I posted in
this thread but, with some modifications for you....
Code:
local function getPlayerColors(unit)
if not UnitExists(unit) then return end
local color
local class = select(2, UnitClass(unit))
if UnitIsPlayer(unit) then
color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
else
color = FACTION_BAR_COLORS[UnitReaction(unit, "player")]
end
return color.r, color.g, color.b
end
local UpdateColor = CreateFrame("Frame")
UpdateColor:RegisterEvent("PLAYER_ENTERING_WORLD")
UpdateColor:RegisterEvent("PLAYER_TARGET_CHANGED")
UpdateColor:RegisterEvent("PLAYER_FOCUS_CHANGED")
UpdateColor:RegisterEvent("UNIT_FACTION")
UpdateColor:SetScript("OnEvent", function(_, event)
_G["PlayerFrameNameBackground"]:SetVertexColor(getPlayerColors("player"))
_G["TargetFrameNameBackground"]:SetVertexColor(getPlayerColors("target"))
_G["FocusFrameNameBackground"]:SetVertexColor(getPlayerColors("focus"))
end)
for _, BarTextures in pairs({TargetFrameNameBackground, FocusFrameNameBackground, PlayerFrameNameBackground}) do
BarTextures:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
end
btw, PLAYER_FRAME_CHANGED will not work as it's not a valid event. ->
https://wow.gamepedia.com/Events
I can't test this right now but, it should work.