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");
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
UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
end;
if UnitAffectingCombat("player") then
UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
end;
end);
addon:SetScript("OnUpdate", function(self, elapsed)
local speed = GetUnitSpeed("player");
if speed ~=0 then
UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
else
if GetMouseFocus() then
if GetMouseFocus():GetName() ~= "WorldFrame" then
UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
else
if not UnitAffectingCombat("player") then
UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
end;
end;
end;
end;
if UnitName("mouseover") then
UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
end;
end);
- When showing the UI, it should be instantly showed with 100% opacity, no fade-in
- There should be a wait time of 3 or 4 seconds, and then the UI fades over 2 seconds. This is a more smooth transition and works better with the 'soft AFK detection' interaction.