In my game, I have added a Main Menu user interface to display when the user loads the application.
In this post, I will mention the two different sets of blueprint classes which I used to add a Main Menu feature.
FirstPersonGameMode blueprint:
I started with adding an event, on the start of the game (Event BeginPlay). On this event, the game will display a widget (using Create Main Menu Widget), and add it to the camera viewport (using Add to Viewport). The player's input will be disabled using Disable Input (inheriting from GetPlayerCharacter and GetPlayerController). I will then set ShowMouseCursor to true.
Main Menu widget blueprint:I started with adding an event, on the start of the game (Event BeginPlay). On this event, the game will display a widget (using Create Main Menu Widget), and add it to the camera viewport (using Add to Viewport). The player's input will be disabled using Disable Input (inheriting from GetPlayerCharacter and GetPlayerController). I will then set ShowMouseCursor to true.
To add a user interface element, I have used a Widget component in Unreal. The widget for my game includes two buttons - one button is used to load the game, and the other button is used to quit the application. On the buttons, I used the OnClicked event to execute a series of functions.
When the user clicks the Play Game button, it will remove the widget from the parent object, set 'Show Mouse Cursor' to hide, and enable the input. When the user clicks the Quit Game button, it will run the built-in Quit Game node.
| Graph view of the Main Menu widget |
| Designer view of the Main Menu widget |
| In-game view of the Main Menu widget |
Conclusion
I felt this was a difficult concept to add to my game, in comparison to Unity. In Unity, the developer can use an in-game Canvas game object to set up and display user interface elements. However, in Unreal, I was not able to find a way to physically display the UI in the game scene.
I feel I could have also made the Main Menu widget in an alternate scene, which could have made it easier.



