Depends on what you mean by "selected unit".
If you want to highlight
the frame the mouse is currently over, the simplest solution is to simply add a highlight texture to the frame:
Code:
self:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
If you want to have more control over what happens (such as changing the color of the health bar) instead of showing/hiding a simple full-sized texture, you can handle that in the frame's OnEnter and OnLeave scripts:
Code:
self:HookScript("OnEnter", function(self)
-- do stuff here when the mouse moves over the frame
end)
self:HookScript("OnLeave", function(self)
-- do stuff here when the mouse moves off the frame
end)
If you want to highlight
the frame whose unit you are currently targeting, you would need to register the PLAYER_TARGET_CHANGED event on your frame:
Code:
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self.PLAYER_TARGET_CHANGED = function(self)
if UnitExists("target") and UnitIsUnit(self.unit, "target") then
-- you are currently targeting this frame's unit
else
-- you are not targeting this frame's unit
end
end