
Hello, my name is Dmitry. I create computer games on the Unreal Engine as a hobby. When developing games, each of us is faced with the need to create a game menu in which you can make adjustments, as well as choose game modes. In this article I will show how I solved this problem. As usual, all the sources will be presented at the end of the article.
I packed all the code in a plugin. After you copy the plugin into your project, you will need to create a new HUD class, which should be derived from MainMenuPluginHUD. Through this class all control is exercised. Here are its settings.
TextScale, MarkColor, MarkLenght - Parameters responsible for displaying information on the radar.
')
SoundClass - In the settings there is a volume level, respectively, here you need to place the SoundClass to which the sounds that you want to control will be tied.
MainMenuMapName - The name of the level at which the main menu will be displayed. That is, when loading this level, the MainMenu mode will be enabled on the other levels, the GameScreen mode will be enabled.
Next comes the list of widgets responsible for certain menu modes.
GameScreenWidget - Widget displayed on the game screen.
MainMenuWidget - Main menu displayed at the beginning of the game.
GameMenuWidget - Menus displayed during the game.
SettingsMenuWidget - Settings menu of the game.
KeyBindMenuWidget - Key assignment menu.
TitlesMenuWidget - Menu titles.
ControlWidget - A screen describing the control of the game.
All widgets are located in the Content folder of the plugin, if you don’t see them, you have unchecked the “Show Plugin Content” option.
In addition, there are functions:
SetMainMenuMode - Set the current menu mode as a parameter gets EMainMenuMode.
GetMainMenuMode - Get the current mode.
All menu modes are described in the MainMenuMode.h file. Add new modes or delete old ones there.
ButtonClick and GetButtonName - Required for button operation. The buttons contain the EMainMenuPluginButtonType variable inside themselves and when the button is pressed or spawned, the corresponding function is called with this parameter.
All buttons are described in the MainMenuPluginButtons.h file. You need to add and delete buttons there.
SetPropertyInt, GetPropertyInt, GetPropertyNameInt - Same for the widget SIntProperty_Wiget. This widget is designed to display integers in the settings menu. In addition to the Int parameters, there are also bool and float.
All parameters are described in the MenuSettingsProperty.h file.
In addition to HUD, you need to create a GameInstanse class derived from MainMenuGameInstance. In order for Game instanse to work, you must select it in ProjectSettings-> Maps & Modes-> GameInstanseClass. This will allow you to display the loading screen. (The loading screen does not work when you start the game in the viewport)
GameInstanse has only two parameters:
LoadingScreenWidget - Widget that displays when loading.
LogoMovie - The name of the movie with the logo (without permission). The movie must necessarily lie in the Content / Movies folder of your project in other folders it can not be put. The video must have a resolution of 720p and a frame rate of 25fps, otherwise the UE will not be able to reproduce it, this is strange considering the fact that Epiki themselves spread the Logo on their website at 1080p and 60fps.
That's all.
Link to download the pluginUpdate
I packed all the HUD code into actor component, now there is no need to make my HUD derived from MainMenuPluginHUD. Just add the UMainMenuPluginHUDComponent component to the HUD.
