G—P / FMX 320 / Tutorials / Tutorial 04

Tutorial 04 · Interface

Menus that work 40 min

Menus in Unreal are Widget Blueprints built in UMG, the Unreal Motion Graphics editor. Three ideas cover every menu you will build: a widget holds the layout, a button event does the work, and the input mode decides whether the mouse talks to the menu or the game.

Start Any level that plays; Tutorial 00's project is fineTime 40 minutes · 25 to build the three menus, 15 for habits and an in-world widgetNeed Common UI plugin only for the last habitServes Every playable deliverable from Week 8 on; a build without a pause menu is not finished

Download the demo projectUETutorials-demo.zip, 71 MB. Unzip it and open the .uproject in Unreal 5.8 to follow along.

Download the answer keyUETutorials-answer-key.zip, 72 MB. Play starts at UI/MainMenu. Escape pauses the game.

By the end of this tutorial you can

Brief · 5 min Three menus, three lessons

MenuOpened fromTeaches
Main menuIts own empty level, MainMenu, set as the Game Default MapCreate Widget, Add to Viewport, Set Input Mode UI Only, Open Level
Pause menuEscape key in the gameplay levelSet Game Paused, Set Input Mode Game and UI, Remove from Parent, toggling
SettingsA button on either menuSliders and combo boxes bound to Game User Settings, Apply Settings, Save

Build · 25 min Main, pause, settings

  1. Lay out the main menu

    Create a Widget Blueprint WBP_MainMenu. Drop in a Canvas Panel, then a Vertical Box anchored to the center. Add a Text Block for the title and three Buttons, each with a Text Block child: Play, Settings, Quit. Set the buttons to 300 by 60 and give them a hover tint so you can see focus change.

    WBP_MainMenu in the Designer: a Canvas Panel, a Vertical Box anchored to the centre, a title and the Play, Settings and Quit buttons.
  2. Wire the buttons

    Select the Play button, scroll to Events in the Details panel, click the plus beside On Clicked. In the graph, call Open Level by Name with the gameplay level's name. Quit calls Quit Game. Settings calls Create Widget on WBP_Settings and Add to Viewport, then Remove from Parent on self.

    The widget's Graph. Each On Clicked event came from the plus button in the Details panel; Play is wired to Open Level by Name.
  3. Show it on start

    Create a blueprint PC_Menu from Player Controller. On Begin Play: Create Widget WBP_MainMenu, Add to Viewport, Set Input Mode UI Only, Set Show Mouse Cursor true. Create a Game Mode blueprint GM_Menu that uses PC_Menu and an empty Default Pawn. In the MainMenu level's World Settings pick GM_Menu, and in Project Settings set Game Default Map to MainMenu.

  4. Build the pause menu

    Create WBP_Pause with Resume, Settings and Main Menu buttons. In the gameplay Player Controller, add an Enhanced Input action IA_Pause bound to Escape. On Triggered: if the pause widget is not valid, create it, Add to Viewport, Set Game Paused true, Set Input Mode Game and UI, show the cursor. Resume reverses all four and clears the reference. On IA_Pause set Execute when Paused to true, or the Escape key dies the moment the game pauses.

    WBP_Pause over the paused game in Play-in-Editor.
  5. Build settings

    Create WBP_Settings. Add a Slider for master volume, a Combo Box (String) for resolution, and a Check Box for fullscreen. On Value Changed of the slider, set a Sound Class volume. On the combo box, call Get Game User Settings, Set Screen Resolution, Apply Settings, then Save Settings. Fill the combo box on Construct from Get Supported Fullscreen Resolutions.

    WBP_Settings in Play-in-Editor: the volume slider, the resolution combo box and the fullscreen check box.
  6. Test it like a build

    Press Play from the MainMenu level with Standalone Game selected, so the Game Default Map and resolution changes behave as they will in a packaged build.

Build · 10 min Habits worth keeping

A menu on an object in the world

A menu that floats over a vending machine or a door panel is the same widget placed in a Widget Component on the actor, with Space set to World and Receive Hardware Input on. Point a Widget Interaction component from the character's camera at it, and clicks pass through to the buttons. Five minutes once the pause menu exists.

Before you close this

Read next