lua Code:
local addon = CreateFrame("Frame");
addon:RegisterEvent("PLAYER_LOGIN");
addon:RegisterEvent("PLAYER_REGEN_DISABLED");
addon:RegisterEvent("PLAYER_REGEN_ENABLED");
addon:RegisterEvent("PLAYER_STARTED_MOVING");
addon:RegisterEvent("PLAYER_STOPPED_MOVING");
addon:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN"
or event == "PLAYER_REGEN_DISABLED"
or event == "PLAYER_STOPPED_MOVING" then
if not UnitAffectingCombat("player") then
UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0);
end;
else
UIParent:SetAlpha(1);
end;
if UnitAffectingCombat("player") then
UIParent:SetAlpha(1);
end;
end);
addon:SetScript("OnUpdate", function(self, elapsed)
local speed = GetUnitSpeed("player");
if speed ~=0 then
UIParent:SetAlpha(1);
else
if GetMouseFocus() then
if GetMouseFocus():GetName() ~= "WorldFrame" then
UIParent:SetAlpha(1);
else
if not UnitAffectingCombat("player") then
UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
end;
end;
end;
end;
if UnitName("mouseover") then
UIParent:SetAlpha(1);
end;
end);
I tried to workaround the fade-in problem by changing it to SetAlpha(1).
It let to lots of clunky interactions, with the UI fading down and then showing up and then disappearing again, only to be hard to make it appear again and such. Lots of suboptimal interactions.