API UnitName

Returns the name and realm of the unit.
 name, realm = UnitName(unit)
 = UnitFullName(unit)
 = UnitNameUnmodified(unit)
==Arguments==
:;unit: : UnitId - For example "mouseover" or "player" or "target"
==Returns==
:;name: - 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: - The normalized realm the unit is from, e.g. "DarkmoonFaire". Returns nil if the unit is from the same realm.
==Details==
*Will return globalstring UNKNOWNOBJECT "Unknown Entity" if called before the unit in question has been fully loaded into the world.
*The unit name will change if the unit is under the effects of Lifegiving Seed or a similar effect, but UnitNameUnmodified() is unaffected by this.
==Example==
*Prints your character's name.
/dump UnitName("player") -- "Leeroy", nil
*Prints the name and realm of your target (if different).
/dump UnitName("target") -- "Thegnome", "DarkmoonFaire"
* UnitFullName() is equivalent with UnitName() except it will always return realm if used with the "player" UnitId.
/dump UnitFullName("player") -- "Leeroy", "MoonGuard"
/dump UnitFullName("target") -- "Leeroy", nil
==GetUnitName==
GetUnitName(unit [, showServerName]) can return the combined unit and realm name.
*If showServerName is true and the queried unit is from a different server, then the return value will include the unit's name appended by a dash and the normalized realm name.
*If showServerName is false, then FOREIGN_SERVER_LABEL " (*)" will be appended to units from coalesced realms. Units from the player's own realm or Connected Realms get no additional suffix.
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==
==See also==
*()