From 1f6d729d73b685f62643ef5f9f473d2bc37e6041 Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 14 Nov 2023 23:16:10 +0000 Subject: [PATCH] Add functionality to open a UWorld when clicking New Game button in main menu --- Source/Nakatomi/MainMenuUIWidget.cpp | 8 +++++++- Source/Nakatomi/MainMenuUIWidget.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Nakatomi/MainMenuUIWidget.cpp b/Source/Nakatomi/MainMenuUIWidget.cpp index 5f5a9cc..8aaabf6 100644 --- a/Source/Nakatomi/MainMenuUIWidget.cpp +++ b/Source/Nakatomi/MainMenuUIWidget.cpp @@ -3,6 +3,8 @@ #include "MainMenuUIWidget.h" +#include "Kismet/GameplayStatics.h" + void UMainMenuUIWidget::NativeConstruct() { Super::NativeConstruct(); @@ -30,7 +32,11 @@ void UMainMenuUIWidget::NativeConstruct() 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() diff --git a/Source/Nakatomi/MainMenuUIWidget.h b/Source/Nakatomi/MainMenuUIWidget.h index 5658349..3124ba8 100644 --- a/Source/Nakatomi/MainMenuUIWidget.h +++ b/Source/Nakatomi/MainMenuUIWidget.h @@ -38,6 +38,9 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TSubclassOf OptionsMenuWidget; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + TSoftObjectPtr NewGameLevel; + private: UUserWidget* currentNewGameWidget;