Creating and Removing Widgets in UEFN
The following sections show how to add a widget to a player’s UI and remove a widget.
These examples use a text block widget, but you can use any kind of widget. See Widget Types for all the types of widgets you can use.
Adding a Widget
This example shows how to add a widget when a player interacts with a Button device in the level:
- Create a new Verse device and add it to the level. To learn how to create a new device in Verse, see Create Your Own Device Using Verse.
- Open your Verse file in Visual Studio Code with Verse Explorer.
- Add an editable Button device property to your Verse device and set up the reference to the Button device in your level. To learn how to create editable properties, see Customize Device Properties.
# Set the Button device in the Editor to reference the device in the level @editable MyButton : button_device = button_device{} - At the top of your Verse file, add the following lines to use the Verse UI API:
using { /UnrealEngine.com/Temporary/UI } using { /Fortnite.com/UI } using { /UnrealEngine.com/Temporary/SpatialMath} - This UI is only per player, so you'll need a reference to a player to access their UI. This example shows how to display a custom UI when the player interacts with a button, since events for devices include a reference to the player that interacted with the device. To learn how to set up event subscriptions, see Coding Device Interactions.
`# 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 =Display UI`
- Now, you can call the failable function
GetPlayerUI[]in an if expression to get a reference to the player’s UI.
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.