Add functionality to open a UWorld when clicking New Game button in main menu

This commit is contained in:
baz 2023-11-14 23:16:10 +00:00
parent 085fd8ea46
commit 1f6d729d73
2 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,8 @@
#include "MainMenuUIWidget.h" #include "MainMenuUIWidget.h"
#include "Kismet/GameplayStatics.h"
void UMainMenuUIWidget::NativeConstruct() void UMainMenuUIWidget::NativeConstruct()
{ {
Super::NativeConstruct(); Super::NativeConstruct();
@ -30,7 +32,11 @@ void UMainMenuUIWidget::NativeConstruct()
void UMainMenuUIWidget::NewGameButtonOnClicked() void UMainMenuUIWidget::NewGameButtonOnClicked()
{ {
// TODO: Implement Functionality // TODO: Replace this is a menu to confirm the user wants to start a new game
if (!NewGameLevel.IsNull())
{
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewGameLevel);
}
} }
void UMainMenuUIWidget::LoadGameButtonOnClicked() void UMainMenuUIWidget::LoadGameButtonOnClicked()

View File

@ -38,6 +38,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> OptionsMenuWidget; TSubclassOf<class UUserWidget> OptionsMenuWidget;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSoftObjectPtr<UWorld> NewGameLevel;
private: private:
UUserWidget* currentNewGameWidget; UUserWidget* currentNewGameWidget;