Набросал в принципи. Иконки появляются при наведении мышкой и сохраняются до выхода из игры для текущих имен. При следующем входе заново мышкой водить =) Можно в принципи для юнитов сделать , но пока так.

PHP код:
local iconSize = 30; -- размер
local iconX = 0; -- х позиция
local iconY = 0; -- у позиция
local nameplates, guids, select = {}, {}, select;
local handler = CreateFrame("frame")
handler:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
local function IsNamePlate(frame)
if frame:GetName() then return false; end
if frame:GetID() ~= 0 then return false; end
if frame:GetObjectType() ~= "Frame" then return false; end
if frame:GetNumChildren() == 0 then return false; end
if frame:GetNumRegions() == 0 then return false; end
return true;
end
local function CreateClassIcon(self)
if self.done then return; end
local glow, overlay, castbarOverlay, shielded, spellIcon, highlight, nameText, levelText, bossIcon, raidIcon, stateIcon = self:GetRegions()
local classIcon = CreateFrame("frame", nil, self);
classIcon:SetSize(iconSize,iconSize);
classIcon:SetPoint("RIGHT", self, "LEFT", iconX,iconY)
local classTex = classIcon:CreateTexture(nil, "BACKDROP");
classTex:SetAllPoints();
self.classIcon = classIcon;
self.classTex = classTex;
self.nameText = nameText;
self.done = true;
end
local function Plate_OnShow(self)
if self.nameText and guids[self.nameText:GetText()] then
self.classTex:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
self.classTex:SetTexCoord(unpack(CLASS_ICON_TCOORDS[guids[self.nameText:GetText()]]))
else
self.classTex:SetTexture("")
end
end
local function Plate_OnHide(self)
end
do
local function IsMouseover(frame)
local region = select(6, frame:GetRegions());
if region and region.IsShown then
return region:IsShown() and true or false;
end
return false
end
function handler:UPDATE_MOUSEOVER_UNIT()
guids[select(1, UnitName("mouseover"))] = select(2, UnitClass("mouseover"))
if GetMouseFocus():GetName()=="WorldFrame" then
for frame in pairs(nameplates) do
if frame:IsShown() and IsMouseover(frame) then
if frame.classTex then
frame.classTex:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
frame.classTex:SetTexCoord(unpack(CLASS_ICON_TCOORDS[select(2, UnitClass("mouseover"))]))
end
else
if frame.nameText and guids[frame.nameText:GetText()] then
frame.classTex:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
frame.classTex:SetTexCoord(unpack(CLASS_ICON_TCOORDS[guids[frame.nameText:GetText()]]))
else
frame.classTex:SetTexture("")
end
end
end
end
end
end
local Findnameplates;
do
local lastChildren = 0
local time = 0
Findnameplates = function(self, elapsed)
time = time + elapsed
if time < .2 then return end
local curChildren = self:GetNumChildren()
if curChildren~=lastChildren then
lastChildren = curChildren
for i = 1, curChildren do
local frame = select(i, self:GetChildren())
if frame:IsShown() and IsNamePlate(frame) and not nameplates[frame] then
CreateClassIcon(frame)
frame:HookScript("OnHide", Plate_OnHide)
frame:HookScript("OnShow", Plate_OnShow)
nameplates[frame] = frame
end
end
end
time = 0
end
end
WorldFrame:HookScript("OnUpdate", Findnameplates)
handler:RegisterEvent("UPDATE_MOUSEOVER_UNIT")