Very easily. The
Subclass method that ZOS have implemented is nothing but a pretty way to update the
meta table of a table, so you have acess to that class just by using the 'getmetatable' method.
Incidentally I had to access the same class you're looking for right now, and here's how I've done it:
Lua Code:
local sampleUnitFrame = ZO_UnitFrames_GetUnitFrame("reticleover")
UnitFrame = getmetatable(sampleUnitFrame)
UnitFrameBar = getmetatable(sampleUnitFrame.healthBar)
Please note that changing methods of the class only affect its instances if they haven't overridden said method.
About UNITFRAME_BAR_STYLES you've answered it yourself, you can't change that. But I have been in situations where I had the same need you have now. A nice example would be this one, from the same add-on I took the first snippet:
Lua Code:
local function ImproveTargetUnitFrame()
local unitFrame = ZO_UnitFrames_GetUnitFrame("reticleover")
local healthBar = unitFrame.healthBar
local healthBarControl = healthBar.barControls[1]
local healthBarLabel = CreateControlFromVirtual(healthBarControl:GetName().."SiufLabel", healthBarControl, "SiufLabel")
healthBarLabel:SetText(GetBarText(healthBar.currentValue, healthBar.maxValue))
healthBarLabel:SetFont("SiufLabelFont")
healthBarLabel:SetAnchor(CENTER, nil, RIGHT, 0, 0)
local previousValue
function unitFrame:RefreshUnit(unitChanged)
UnitFrame.RefreshUnit(self, unitChanged)
if unitChanged then
previousValue = nil
end
end
function healthBar:UpdateText(...)
-- UnitFrameBar.UpdateText(self, ...)
healthBarLabel:SetText(GetBarText(self.currentValue, self.maxValue, previousValue))
previousValue = self.currentValue
end
end
You can see above how I override some methods of the instance, and call the same method but now from the class to keep the same functionality without having to write it myself.