All default controls in game UI are shown/hidden using the scene manager:
Create a simple scene fragment:
Lua Code:
local fragment = ZO_SimpleSceneFragment:New(yourTopLevelWindow)
or scene fragment with fade in/out animation:
Lua Code:
local fragment = ZO_FadeSceneFragment:New(yourTopLevelWindow)
or HUD scene fragment with fade in/out animation:
Lua Code:
local fragment = ZO_HUDFadeSceneFragment:New(yourTopLevelWindow, showDuration, hideDuration)
And then add your fragment to all scenes where it has to be shown:
Lua Code:
local scene = SCENE_MANAGER:GetScene("hud")
scene:AddFragment(fragment)
If you want to add more fragments at once you can create fragment group:
Lua Code:
local fragmentGroup = { fragment1, fragment2, fragment3 }
scene:AddFragmentGroup(fragmentGroup)
If you want to remove fragment from the scene use:
Lua Code:
scene:RemoveFragment(fragment)
Another method is to show/hide fragments on demand in the current scene by calling:
(fragments are added to the scene just temporarily - until the scene is hidden)
Lua Code:
SCENE_MANAGER:AddFragment(fragment)
SCENE_MANAGER:RemoveFragment(fragment)
SCENE_MANAGER:AddFragmentGroup(fragmentGroup)
SCENE_MANAGER:RemoveFragmentGroup(fragmentGroup)
How to check which scene is currently active:
Code:
/script d(SCENE_MANAGER:GetCurrentScene():GetName())
Or you can look into the SCENE_MANAGER.scenes table, which contains reference to all registered scenes.
Example:
Lua Code:
--simple window with a texture:
local tlw, texture
tlw = WINDOW_MANAGER:CreateTopLevelWindow()
tlw:SetDimensions(100,100)
tlw:SetAnchor(CENTER, GuiRoot, CENTER, 0, 0)
tlw:SetHidden(true)
texture = WINDOW_MANAGER:CreateControl(nil, tlw, CT_TEXTURE)
texture:SetTexture("/esoui/art/icons/poi/poi_groupboss_complete.dds")
texture:SetAnchorFill(tlw)
--create a scene fragment (1000ms show duration, 500ms hide duration)
local fragment = ZO_HUDFadeSceneFragment:New(tlw, 1000, 500)
--add my fragment to scenes:
HUD_SCENE:AddFragment(fragment)
HUD_UI_SCENE:AddFragment(fragment)
Note:
In some cases you can break fast travel system if you add fade scene fragment to the "hud" scene (fast travel using the wayshrine costs money). If it happens, use ZO_HUDFadeSceneFragment or ZO_SimpleSceneFragment instead of ZO_FadeSceneFragment.