Hey! I'm updating this post to expose my advancement on the subject.
The previous answers have helped and learned me a lot. So I would therefore like to thank them once again.
At first, I obstinately continued in the way that has been suggested. I tried to fix the issue encountered with
SetMask() while in combat. But I didn't found anything pertinent in the Blizzard interface.
So I decided to try as I thought with a folder containing my textures in order to avoid
SetMask().
And I achieved to something working perfectly as expected. It's like this:
Lua Code:
hooksecurefunc("UnitFramePortrait_Update", function(self)
if self.portrait then
if UnitIsPlayer(self.unit) then
local race = ((select(2,UnitRace(self.unit))):lower());
local gender = (UnitSex(self.unit) == 3);
if gender then
self.portrait:SetTexture(string.format("Interface\\AddOns\\RaceIconPortrait\\Textures\\%s-%s.tga", race, "female"))
else
self.portrait:SetTexture(string.format("Interface\\AddOns\\RaceIconPortrait\\Textures\\%s-%s.tga", race, "male"))
end
end
if UnitIsPlayer("target") then
TargetFramePortrait:SetTexCoord(1,0,0,1)
else
TargetFramePortrait:SetTexCoord(0,1,0,1)
end
if UnitIsPlayer("focus") then
FocusFramePortrait:SetTexCoord(1,0,0,1)
else
FocusFramePortrait:SetTexCoord(0,1,0,1)
end
end
end)
I'm conscious that it could be better, especially with the
UnitSex() and the second
%s (I have particularly struggled with this, for finally end up to this). Also I have add the functionality to reverse the portrait for the target and focus frame. If you have any suggestion I'll be glad to read them.