View Single Post
07/11/16, 12:25 PM   #8
tgolsson
Join Date: Jul 2016
Posts: 5
Originally Posted by sirinsidiator View Post
Welcome to ESOUI and addon development!

If you haven't already read the Getting Started guide, I suggest you take a look to find out where you can find "documentation" and useful info about the API.

For something like group unit frames you should create the controls once when you need them and keep a table where you associate a unitTag to the frame control.

Lua Code:
  1. local unitFrames = {}
  2. local function GetUnitFrame(unitTag)
  3.   if(not unitFrames[unitTag]) then
  4.     unitFrames[unitTag] = CreateControlFromVirtual("Target", GuiRoot, "UnitFrame")
  5.   end
  6.   return unitFrames[unitTag]
  7. end

Whenever you react to some change to a group member you would then just call GetUnitFrame and pass the unitTag of the affected player.

One thing you should keep in mind when creating controls is that for every control you create, a global variable is generated implicitly. Meaning you should not call a control "Target" or "UnitFrame", but instead "MyUnitFrameAddonTarget" and "MyUnitFrameAddonUnitFrameTemplate" to avoid name collisions.
How would I change the label inside the unit frame, in this case? Because that is my original problem.
  Reply With Quote