Verse Library verse

01 Snippet

Creates a reusable UI button component that cycles through predefined options, updating its displayed text dynamically.

extracted-snippets/community/snippets/ARdv/fortnite-state-button/01-snippet.verse

# Source URL: https://dev.epicgames.com/community/snippets/ARdv/fortnite-state-button
# Local doc:  epic-docs/community/snippets/ARdv/fortnite-state-button.md
  using { /Fortnite.com/UI }
  using { /UnrealEngine.com/Temporary/UI }
  StateButtonDefaultText<public><localizes>:message="Default Text"
  state_button_option<public> := interface<castable>:
  Title<public>:message
  GetTitle<public>():message=
  Title
  state_button_default_option<public> := class(state_button_option):
  Title<override>:message = StateButtonDefaultText
  state_button_base<public> := class<abstract>:
  Button<public>:text_button_base
  Options<public>:[]state_button_option
  var<private> CurrentOptionIndex<public>:int = 0
  GetWidget<public>():widget=
  Update()
  Button
  Update<public>():void=
  ActiveIndex := Clamp(CurrentOptionIndex, 0, Options.Length - 1)
  if:
  TargetOption := Options[ActiveIndex]
  then:
  Button.SetText(TargetOption.GetTitle())
  SetOption<public>(Index:int):void=
  set CurrentOptionIndex = Clamp(Index, 0, Options.Length - 1)
  Update()
  SetOption<public>(option_type:castable_subtype(state_button_option)):void=
  for:
  Index -> Option : Options

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.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in