# Source URL: https://dev.epicgames.com/community/learning/tutorials/B9my/fortnite-uefn-ui-example-for-using-verse-input-and-the-ui-back-action-to-close-a-menu
# Local doc: epic-docs/community/learning/tutorials/B9my/fortnite-uefn-ui-example-for-using-verse-input-and-the-ui-back-action-to-close-a-menu.md
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Input }
using { /Verse.org/Input/UI }
ui_mode_device := class(creative_device):
# The volume to open the UI.
@editable
ShowVolume : volume_device = volume_device{}
# Your UMG widget.
RootWidget : UserInterfaces.UW_ActionWidget = UserInterfaces.UW_ActionWidget{}
var CurrentPlayer : ?player = false
OnBegin<override>() : void =
ShowVolume.AgentEntersEvent.Subscribe(OnAgentEntered)
# Fires when any agent walks into the volume
OnAgentEntered(Agent : agent) : void =
if (Player := player[Agent]):
set CurrentPlayer = option{ Player }
OpenUI(Player)
# Spawns the UI on screen and switches the player into UI input mode
Verse Library
verse
01 Snippet
Adds a UMG menu on volume entry, maps navigation inputs, and handles the back button to close it.
extracted-snippets/community/learning/tutorials/B9my/fortnite-uefn-ui-example-for-using-verse-input-and-the-ui-back-action-to-close-a-menu/01-snippet.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.