Lua GetUnits

GetUnits
Returns all valid units currently loaded by the client as LuaUnit objects.

NOTE: This function returns a C# List<?> that has not been marshalled. It is recommended that you marshal the results into a Lua table using the provided toTable function, as shown in the example below.

NOTE: It is possible for a unit returned by this function to no longer be valid. If needed, you should verify that by checking IsValid.

Example
-- The result of GetUnits is marshalled to Lua using our toTable function. local units = toTable(GetUnits);

-- Loop all units and print their names to the log. for k, v in pairs(units) do Info("Unit at index " .. k .. " is named " .. v.Name); end