wowpedia
Main Menu


Returns the name and realm of the unit.

name, realm = UnitName(unit)
            = UnitFullName(unit)
            = UnitNameUnmodified(unit)

Arguments

unit
string : UnitId - For example "mouseover" or "player" or "target"

Returns

name
string? - The name of the unit and realm with an interposing space, e.g. Thegnome DarkmoonFaire. Returns nil nil if the unit doesn't exist, e.g. the player has no unit selected.
realm
string? - The normalized realm the unit is from, e.g. "DarkmoonFaire". Returns nil if the unit is from the same realm.

Details

Example

/dump UnitName("player") -- "Leeroy", nil
/dump UnitName("target") -- "Thegnome", "DarkmoonFaire"
/dump UnitFullName("player") -- "Leeroy", "MoonGuard"
/dump UnitFullName("target") -- "Leeroy", nil

GetUnitName

GetUnitName(unit [, showServerName]) can return the combined unit and realm name.

Unit is from the same realm.

/dump GetUnitName("target", true)  -- "Nephertiri"
/dump GetUnitName("target", false) -- "Nephertiri"

Unit is from a different realm but the same Connected Realm (LE_REALM_RELATION_VIRTUAL).

/dump GetUnitName("target", true)  -- "Standron-EarthenRing"
/dump GetUnitName("target", false) -- "Standron"

Unit is from a different, non-connected realm (LE_REALM_RELATION_COALESCED).

/dump GetUnitName("target", true)  -- "Celturio-Quel'Thalas"
/dump GetUnitName("target", false) -- "Celturio (*)"

Patch changes

WoW Icon update Patch 1.12.0 (2006-08-22): Added realm return value.[1]

See also