Add Options Menu to viewport on OptionsButton Clicked

This commit is contained in:
baz 2023-10-06 23:13:52 +01:00
parent dc0ed36573
commit 483add816a
3 changed files with 14 additions and 4 deletions

BIN
Content/UI/TestWidget.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -60,6 +60,11 @@ void UPauseUIWidget::ResumeButtonOnClicked()
void UPauseUIWidget::OptionsButtonOnClicked() void UPauseUIWidget::OptionsButtonOnClicked()
{ {
// TODO: Implement Functionality // TODO: Implement Functionality
if (OptionsMenuWidget)
{
currentOptionsMenuWidget = CreateWidget<UUserWidget>(GetWorld(), OptionsMenuWidget);
currentOptionsMenuWidget->AddToViewport();
}
} }
void UPauseUIWidget::SaveButtonOnClicked() void UPauseUIWidget::SaveButtonOnClicked()

View File

@ -5,7 +5,6 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Blueprint/UserWidget.h" #include "Blueprint/UserWidget.h"
#include "Components/Button.h" #include "Components/Button.h"
#include "Components/VerticalBox.h"
#include "PauseUIWidget.generated.h" #include "PauseUIWidget.generated.h"
/** /**
@ -17,9 +16,6 @@ class NAKATOMI_API UPauseUIWidget : public UUserWidget
GENERATED_BODY() GENERATED_BODY()
public: public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UVerticalBox* VerticalBox;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ResumeButton; UButton* ResumeButton;
@ -35,6 +31,12 @@ public:
UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* ExitGameButton; UButton* ExitGameButton;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> OptionsMenuWidget;
private:
UUserWidget* currentOptionsMenuWidget;
public: public:
virtual void NativeConstruct() override; virtual void NativeConstruct() override;