oUF Nameplates Guide
Basics
You need to modify your style function for it to handle nameplates.
Here's an example style function:
Lua Code:
oUF:RegisterStyle("YourStyle", function(frame, unit)
if unit == "player" then
-- your player-specific code here
elseif unit == "boss1" then
-- your boss1-specific code here
elseif unit:match("nameplate") then
-- health bar
local health = CreateFrame("StatusBar", nil, frame)
health:SetAllPoints()
health:SetStatusBarTexture("Interface\\BUTTONS\\WHITE8X8")
health.colorHealth = true
health.colorTapping = true
health.colorDisconnected = true
frame.Health = health
-- frame background
local bg = frame:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.2, 0.2, 0.2)
-- set size and points
frame:SetSize(128, 16)
frame:SetPoint("CENTER", 0, 0)
end
end)
One important thing to note here is that these nameplates will be parented to the Blizzard nameplate points on WorldFrame.
You can adjust the anchor however you'd like, but you'll have to do it in the style function as seen above.
Spawning nameplates is done like this:
This function behaves much like
oUF:SpawnHeader(), in the way that you only need to call it
once to spawn all the nameplates.
oUF:SpawnNamePlates() takes three (optional) arguements:
- Name prefix
- The default name is "oUF_YourStyleNameplate1", this argument will replace the "oUF_YourStyle" part of it.
- Callback function
- This function will be called after a nameplate unit or the player's target has changed.
- List of nameplate-related CVars.
If you use
oUF:Factory() or use multiple styles, you may want to call
oUF:SetActiveStyle("YourStyle") first.
For more info,
see code and documentation.
Important: Scaling
These nameplates are anchored to the default Blizzard nameplates, which in turn are anchored to WorldFrame.
This means that all nameplates are
not affected by the global UI scale.
To change the scale, use
frame:SetScale(scale) in the style function.
One thing to note is that the scaling is influenced by CVars, and we recommend "resetting" these, like so:
Lua Code:
local cvars = {
-- important, strongly recommend to set these to 1
nameplateGlobalScale = 1,
NamePlateHorizontalScale = 1,
NamePlateVerticalScale = 1,
-- optional, you may use any values
nameplateLargerScale = 1,
nameplateMaxScale = 1,
nameplateMinScale = 1,
nameplateSelectedScale = 1,
nameplateSelfScale = 1,
}
oUF:SpawnNamePlates(nil, nil, cvars)
Important: Protected Nameplates
oUF does
not interact with forbidden nameplates (friendly nameplates in instances), which means you don't need to worry about avoiding these in your layout.