# This is a Verse file. We are creating a custom device.
# Think of this file as the "brain" for our UI gadget.
# 1. DEFINE THE DEVICE
# This tells UEFN that this file is a gadget you can place in the world.
LootTracker : Device =
# This is where we connect our code to the visual widgets in the editor.
# 'MyText' is the name of the Text Widget component you place in the editor.
# 'ResetButton' is the name of the Button component.
MyText : TextWidget = ""
ResetButton : ButtonWidget = ""
# 2. DEFINE THE VARIABLE (The Scoreboard)
# 'loot_count' is our variable. It starts at 0.
# 'mutable' means the number can change later.
loot_count : int = 0
# 3. DEFINE THE FUNCTION (The Action)
# This function runs when the button is clicked.
OnResetClicked := func (button: ButtonWidget) -> void:
# Reset the variable back to zero
loot_count = 0
# Update the text on the widget to show the new count
MyText.SetText("Chests Opened: {loot_count}")
# Optional: Print to chat so you know it worked
Print("Reset complete! Back to zero.")
# 4. DEFINE THE EVENT (The Trigger)
Verse Library
verse
01 Fragment
Updates a text widget dynamically and handles button clicks to reset a collected loot counter.
verse-library/creating-ui-with-verse-in-unreal-editor-for-fortnite/01-fragment.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.