Returns a unit's class. The second return (classFileName
) can be used for locale-independent verification of a unit's class, or to look up class-related data in various global tables:
RAID_CLASS_COLORS
provides a standard color for each class (as seen in the default who, guild, calendar, and raid UIs)CLASS_ICON_TCOORDS
provides coordinates to locate each class' icon within the "Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes" texture
For non-player units, the first return (class
) will be the unit's name; to always get a localized class name regardless of unit type, use UnitClassBase
instead.
See also Unit functions.
Signature:
class,
classFileName,
classIndex
=
UnitClass("unit")
or
UnitClass("name")
Arguments:
unit
- A unit to query (string
, unitID)name
- Name of a unit to query; only valid forplayer
,pet
, and party/raid members (string
)
Returns:
class
- The localized name of the unit's class, or the unit's name if the unit is an NPC (string
)classFileName
- A non-localized token representing the class (string
)classIndex
- ID of the class (number
)
Examples:
-- Print the name of your target in a class-specific color local class, classFileName = UnitClass("target") local color = RAID_CLASS_COLORS[classFileName] ChatFrame1:AddMessage(class, color.r, color.g, color.b)