If I just add it in the spawn fieid, it would not work properly for me. When I change units, the old mark won't go away.
This is what I currently do.
Code:
local function UpdateTargetMark(self)
local mark = self.targetMark
if not mark then return end
if UnitIsUnit(self.unit, "target") and not UnitIsUnit(self.unit, "player") then
mark:SetAlpha(1)
else
mark:SetAlpha(0)
end
end
oUF:RegisterStyle("Nameplates", function(self, unit)
...
local arrow = self:CreateTexture(nil, "OVERLAY")
arrow:SetSize(50, 50)
arrow:SetTexture(arrowTexture)
arrow:SetPoint("BOTTOM", self, "TOP", 0, 14)
arrow:SetAlpha(0)
self.targetMark = arrow
self:RegisterEvent("PLAYER_TARGET_CHANGED", UpdateTargetMark)
...
end)
oUF:SpawnNamePlates("oUF_NPs", function(self, _, unit)
...
UpdateTargetMark(self)
...
end)
I have no idea why I need to update it in two places to make it work.