View Single Post
08-20-21, 12:02 PM   #1
Nagí
A Murloc Raider
 
Nagí's Avatar
Join Date: Oct 2020
Posts: 6
Race Icon Portrait

Hi, I'm trying to have these race icons to the portrait of my unit frames (player, target, targettarget, arena1, etc...) in the same spirit as the few addons who allow you to have the class icons to portraits. All these addons use a similar structure like this one:
Lua Code:
  1. hooksecurefunc("UnitFramePortrait_Update",function(self)
  2.         if self.portrait then
  3.                 if UnitIsPlayer(self.unit) then                        
  4.                         local t = CLASS_ICON_TCOORDS[select(2, UnitClass(self.unit))]
  5.                         if t then
  6.                                 self.portrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  7.                                 self.portrait:SetTexCoord(unpack(t))
  8.                         end
  9.                 else
  10.                         self.portrait:SetTexCoord(0,1,0,1)
  11.                 end
  12.         end
  13. end)

I attempted some modifications by my own, of course it resulted nothing...
I presume that I should replace "CLASS_ICON_TCOORDS" by "RACE_ICON_TCOORDS", add "UnitSex" and replace "UnitClass" by "UnitRace".

Maybe it needs more changes or another structure. Honnestly I don't know, I'm lost with many questions like: UnitGUID wouldn't be better? / What about C_PlayerInfo.GetRace? Etc... I can't even figure if what I ask for is possible or not.

My knowledge are very limited in coding, I think I'm able to read and nearly understand line after line
but not to write it all by myself without some guidance. Could someone help me with this?
Attached Files
File Type: blp charactercreateicons.blp (2.00 MB, 198 views)
  Reply With Quote