function BasicUnitFrames_Button_OnLoad(self) self:RegisterForDrag("LeftButton") self:RegisterEvent("UNIT_HEALTH") self:RegisterEvent("UNIT_MAXHEALTH") self.healthbar = getglobal(self:GetName().."_HealthBar") self.name = getglobal(self.GetName().."_Name") end function BasicUnitFrames_Button_OnShow(self) local unit = self.GetAttribute("unit") if unit then self.name:SetText(UnitName(unit)) local class = select(2, UnitClass(unit)) or "WARRIOR" local color = RAID_CLASS_COLORS[class] self.healthbar:SetStatusBarColor(color.r, color.g, color.b) end end function BasicUnitFrames_Button_OnEvent(self, event, ...) local unit = ... if self:GetAttribute("unit") == unit then if event == "UNIT_MAXHEALTH" then self.healthbar:SetMinMaxValues(0, UnitHealthMax(unit)) self.healthbar:SetValue(UnitHealth(unit)) elseif event == "UNIT_HEALTH" then self.healthbar:SetValue(UnitHealth(unit)) end end end function BasicUnitFrames_Button_OnDragStart(self, button) BasicUnitFrames_Header:StartMoving() BasicUnitFrames_Header:StopMovingOrSizing() end function BasicUnitFrames_Button_OnDragStop(self, button) if BasicUnitFrames_Header.isMoving then BasicUnitFrames_Header:StopMovingOrSizing() end end