Here's what I do on mine. It hooks
NameplateDriverFrame:OnNamePlateCreated() when it creates nameplates and
CompactUnitFrame_UpdateHealth() to update. I also store a mapping between the unitframe and the text to prevent collisions with other addons or future additions from Blizzard.
Lua Code:
local NamePlateHealthText={};
hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(self,base)-- Hook Nameplate creation
local unitframe=base.UnitFrame;
local health=unitframe.healthBar:CreateFontString(nil,"OVERLAY");
health:SetFont("Fonts\\ArialN.ttf",10,"THICKOUTLINE");-- Fonts are easier to read when made from scratch rather than resizing an inherited one
health:SetPoint("LEFT");
health:SetTextColor(0,1,0);
NamePlateHealthText[unitframe]=health;
end);
hooksecurefunc("CompactUnitFrame_UpdateHealth",function(self)-- This is a shared function with other UnitFrames
if NamePlateHealthText[self] then NamePlateHealthText[self]:SetText(UnitHealth(self.displayedUnit)); end
end);