This is what Blizzard uses fwiw
lua Code:
function CompactUnitFrame_UpdateInRange(frame)
if ( not frame.optionTable.fadeOutOfRange ) then
return;
end
local inRange, checkedRange = UnitInRange(frame.displayedUnit);
if ( checkedRange and not inRange ) then --If we weren't able to check the range for some reason, we'll just treat them as in-range (for example, enemy units)
frame:SetAlpha(0.55);
else
frame:SetAlpha(1);
end
end
https://www.townlong-yak.com/framexm...tFrame.lua#648
frame.background doesn't seem to be a thing here, not sure where you got that code from but it could have been from an older version of the game and raid frames may have changed since, idk.
You can always override this by doing something like this:
lua Code:
hooksecurefunc("CompactUnitFrame_UpdateInRange", function(frame)
if ( not frame.optionTable.fadeOutOfRange ) then
return;
end
local inRange, checkedRange = UnitInRange(frame.displayedUnit);
if ( checkedRange and not inRange ) then --If we weren't able to check the range for some reason, we'll just treat them as in-range (for example, enemy units)
frame:SetAlpha(0.3);
else
frame:SetAlpha(1);
end
end)