Skip to content

Menu

Introduction

A widget used to display menu items and handle navigation between the items

Dependencies

The Menu relies on other components of this plugin to work:

  • Logger: Used to log useful information to help you debug any issues you might experience
  • Game Instance: Used to monitor for input device changes and handle saving/loading game data
  • Audio: Used to play sound effects either 2D or at a specified location

Optional Widgets

You can add the following widgets to enable extra functionality:

Name Description Type
ScrollContainer Scroll container used for large menus with many items UScrollBox*
Container The container used to display the menu items UPanelWidget*

API Reference

Properties

Property Description Type Default Value
HighlightFirstItemOnStart Should the first item be highlighted when the menu is loaded? bool true
AddInputBindingOnLoad Should the input binding automatically be added as soon as the widget is loaded? bool false
PauseGameWhileVisible Should the game automatically be paused/resumed based on the visibility of the menu? bool false
DisableWhilePaused Should the menu be disabled while the game is paused? bool false
SelectedSFX The sound effect played when a menu item is selected USoundBase* nullptr
BackSFX The sound effect played when trying to go back to a previous menu or closing the menu through the back button USoundBase* nullptr
InputMappingContext The input mapping context used to navigate the menu UInputMappingContext* nullptr
MenuUpInputAction The input action used to navigate up UInputAction* nullptr
MenuDownInputAction The input action used to navigate down UInputAction* nullptr
MenuLeftInputAction The input action used to navigate left UInputAction* nullptr
MenuRightInputAction The input action used to navigate right UInputAction* nullptr
MenuSelectInputAction The input action used to select a menu item UInputAction* nullptr
MenuBackInputAction The input action used to go back to a previous menu or close the menu UInputAction* nullptr

Events

Name Description Params
OnBackEvent Event used to handle the back/close action of the menu

Functions

Name Description Params Return
OnMenuUp Navigate up or increase the value
OnMenuUpHold Increase the value while holding the menu up key
OnMenuDown Navigate down or decrease the value
OnMenuDownHold Decrease the value while holding the menu down key
OnMenuLeft Navigate left or decrease the value
OnMenuLeftHold Decrease the value while holding the menu left key
OnMenuRight Navigate right or increase the value
OnMenuRightHold Increase the value while holding the menu right key
OnMenuSelected Select the current menu item
OnMenuBack Go back to a previous menu or close the menu
RequestHighlight Request to highlight a specific menu item MenuItem (UMenuItem*)
The menu item to highlight
RemoveHighlight Request to remove the highlighted state from a specific menu item MenuItem (UMenuItem*)
The menu item to remove the highlighted state from
AddMenuItem Add a menu item to the container MenuItem (UMenuItem*)
The menu item to add

Blueprint Usage

You can use the Menu using Blueprints by adding one of the following nodes:

  • Ultimate Starter Kit > UI > On Menu Up
  • Ultimate Starter Kit > UI > On Menu Up Hold
  • Ultimate Starter Kit > UI > On Menu Down
  • Ultimate Starter Kit > UI > On Menu Down Hold
  • Ultimate Starter Kit > UI > On Menu Left
  • Ultimate Starter Kit > UI > On Menu Left Hold
  • Ultimate Starter Kit > UI > On Menu Right
  • Ultimate Starter Kit > UI > On Menu Right Hold
  • Ultimate Starter Kit > UI > On Menu Selected
  • Ultimate Starter Kit > UI > On Menu Back
  • Ultimate Starter Kit > UI > Request Highlight
  • Ultimate Starter Kit > UI > Remove Highlight
  • Ultimate Starter Kit > UI > Add Menu Item

C++ Usage

Before you can use the plugin, you first need to enable the plugin in your Build.cs file:

PublicDependencyModuleNames.Add("USK");

The Menu can now be used in any of your C++ files:

#include "USK/Widgets/Menu.h"

void ATestActor::Test()
{
    // Menu is a pointer to the UMenu
    Menu->OnMenuUp();
    Menu->OnMenuUpHold();
    Menu->OnMenuDown();
    Menu->OnMenuDownHold();
    Menu->OnMenuLeft();
    Menu->OnMenuLeftHold();
    Menu->OnMenuRight();
    Menu->OnMenuRightHold();
    Menu->OnMenuSelected();
    Menu->OnMenuBack();
    Menu->RequestHighlight(MenuItem);
    Menu->RemoveHighlight(MenuItem);
    Menu->AddMenuItem(MenuItem);
}