View Single Post
07/11/16, 12:04 PM   #3
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
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.
  Reply With Quote