UI /Menu/Interface

3D Menu setup



Create a gamemode base BP, called MainMenu Game Mode

Change game mode override:
image.png

Drag Player Start in the scene

Create a Actor BP called BP_Menu3D
add 2 components and move the camera a bit
image.png


Set Parents and Child Widgets:


Create a widget called Menu3D Widget
Go to Graph, class setting, tick Generat Abstrat Class (avoid directly spawn into world, only spawn children of it)
image.png
Add Event dispatchers
image.png

Create a new widget called Button Widget

Create a new widget called MainMenu Widget
Open it, go to class setting, add the parent class:
image.png

Duplicate the Widget 2 times, rename as follow:
image.png


Create Button Widget:

image.png
create variable text, set as
image.png
Drag Get Button Text first, then type set SetText node, connect as:
image.png

Use variables and nodes to control hover colors:


Create hover and unhover events on button variables, make graph as:
Set Hover Color variable as editable and private
image.png
Repeat the same on unhover node, change background color to RGB and alpha 0
image.png
Create Click event on the button variable, add dispatcher, and set graph as:
image.png


Create MainMenu Widget:

In Design:
image.png
Rename those button widgets

Go to the scene, drag BP menu 3d actor to location where wants to show menu
Set the widget class to mainmenu widget
image.png
Set the draw size same as in main menu widget (set in custom)
image.png
Rotate the widget 180 degree in Viewport in BP menu3d actor
image.png
move the widget to fit the camrea view in scene

Set starting from the camera actor view: (Set Input Mode Game and UI node)

Open level BP:
Select the BP actor in scene
image.png
Unitck hide cursor during capture

Go to BP Menu3D event graph, add custom event (to disable old widget once click to new one, and transit the camera view to new target)
image.png
Back to Level BP
image.png

Test the play mode now, now the mouse can’t click on button
Fix it to go to BP menu 3D, Widget component, turn on Receive Hardware input in interaction
image.png

Duplicate the 3D menu BP actors in other places in the scene

Set NewGame Widget Design:
image.png

Set Option Widget Design:
image.png

make sure both widget set the parents and untick generate abstract class in Class settings, or else they won’t show when choosing below for each BP actor:

image.png
Assign each BP Menu3D actor with corresponding widget
image.png


Link different menu widget with array variable


Back to BP menu3D
Add variable (for linking to different menus)
image.png

Go to BP main menu in scene, now can add array in default in details:
image.png
In 2nd BP menu, add 1 array (coz only 1 button is needed for going back to main menu)
image.png
Repeat the same on remained BP Menu

Go to Menu3D widget, select the transiton to linked menu dispatcher
Add input parameter (click + button) in dispatcher created earlier on (to specific which menu to switch to)
image.png

Go to main menu widget, called the graph as below:
(Menu index number depends on how it sets at the BP mainmenu BP in details:)
image.png

Back to BP Menu 3D actor, modify event graph (plus the linkmenus variable, can create and connect more menu ui easily):

image.png

Set those menus (i.e. New game menu and Option menu) with Back button as:
image.png

To don’t let other widget menu work when we are on the assigned widget menu:
Disable collision
Go to BP Menu 3D
Add Set Actor Enable collision node as below
image.png

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.