View Single Post
08-24-21, 08:41 PM   #7
Nagí
A Murloc Raider
 
Nagí's Avatar
Join Date: Oct 2020
Posts: 6
So I keep search and I found something very interesting and it gives me an idea.
It's an AddOn called EnhancedClassIconPortraits, and this is his core:
Lua Code:
  1. local TEXTURE_NAME = "Interface\\AddOns\\EnhancedClassIconPortraits\\Textures\\%s.tga"
  2.  
  3. hooksecurefunc("UnitFramePortrait_Update", function(self)
  4.     if self.portrait then
  5.         if UnitIsPlayer(self.unit) then
  6.             local _, class = UnitClass(self.unit)
  7.             if class then
  8.                 self.portrait:SetTexture(TEXTURE_NAME:format(class))
  9.             else
  10.                 --[===[@alpha@
  11.                 print(("EnhancedClassIconPortraits Error: UnitClass returned nil for unit %q"):format(self.unit))
  12.                 --@end-alpha@]===]
  13.             end
  14.         end
  15.     end
  16. end)

If I take a similar way as above, I can avoid to call SetMask() and have the same result without performance issue. So I have extracted the textures and applied directly a mask on it. Now I have a folder with 46 icons, here is an example. Maybe the name of the textures in the folder could need to be renamed if I want to call them.

That's probably less efficient than SetAtlas(). What do you think about it? Is that possible?
Attached Files
File Type: tga bloodelf-female.tga (64.5 KB, 202 views)

Last edited by Nagí : 08-24-21 at 08:43 PM.
  Reply With Quote