# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/making-widgets-interactable-in-unreal-editor-for-fortnite
# Local doc: epic-docs/documentation/en-us/fortnite/making-widgets-interactable-in-unreal-editor-for-fortnite.md
# Section: Slider Interactions
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
interactable_slider := class(creative_device):
# Set the Button device in the Editor to reference the device in the level
@editable
MyButton : button_device = button_device{}
# Localizable message to display as text in the UI
TextForMyUI<localizes> : message = "Close"
# A mapping between the Player and the widget that may have been added to their UI
var MaybeMyUIPerPlayer : [player]?canvas = map{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends> : void =
MyButton.InteractedWithEvent.Subscribe(HandleButtonInteraction)
# A custom UI can only be associated with a specific player, and only that player can see it
HandleButtonInteraction(Agent : agent) : void =
if (InPlayer := player[Agent], PlayerUI := GetPlayerUI[InPlayer]):
if (MyUI := MaybeMyUIPerPlayer[InPlayer]?):
PlayerUI.RemoveWidget(MyUI)
if (set MaybeMyUIPerPlayer[InPlayer] = false) {}
else:
NewUI := CreateMyUI()
PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.All})
if (set MaybeMyUIPerPlayer[InPlayer] = option{NewUI}) {}
# Create a UI with an interactable slider, and a button that removes the UI from the screen
Verse Library
verse
06 Slider Interactions
A creative device that displays a custom UI panel containing a slider and close button upon player interaction.
extracted-snippets/documentation/en-us/fortnite/making-widgets-interactable-in-unreal-editor-for-fortnite/06-slider-interactions.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.