diff --git a/Source/Nakatomi/MainMenuUIWidget.cpp b/Source/Nakatomi/MainMenuUIWidget.cpp index 8aaabf6..28c6d39 100644 --- a/Source/Nakatomi/MainMenuUIWidget.cpp +++ b/Source/Nakatomi/MainMenuUIWidget.cpp @@ -3,6 +3,7 @@ #include "MainMenuUIWidget.h" +#include "Blueprint/WidgetBlueprintLibrary.h" #include "Kismet/GameplayStatics.h" void UMainMenuUIWidget::NativeConstruct() @@ -28,6 +29,14 @@ void UMainMenuUIWidget::NativeConstruct() { QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitButtonOnClicked); } + + if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + UWidgetBlueprintLibrary::SetInputMode_UIOnlyEx(PlayerController, this, EMouseLockMode::LockAlways); + PlayerController->bShowMouseCursor = true; + } + + } void UMainMenuUIWidget::NewGameButtonOnClicked() @@ -37,6 +46,14 @@ void UMainMenuUIWidget::NewGameButtonOnClicked() { UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewGameLevel); } + + if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + PlayerController->bShowMouseCursor = false; + UWidgetBlueprintLibrary::SetInputMode_GameOnly(PlayerController); + } + + SetIsFocusable(false); } void UMainMenuUIWidget::LoadGameButtonOnClicked() diff --git a/Source/Nakatomi/OptionsUIWidget.cpp b/Source/Nakatomi/OptionsUIWidget.cpp index 18a5cf1..c0e84ca 100644 --- a/Source/Nakatomi/OptionsUIWidget.cpp +++ b/Source/Nakatomi/OptionsUIWidget.cpp @@ -5,7 +5,9 @@ #include +#include "Blueprint/WidgetBlueprintLibrary.h" #include "GameFramework/GameUserSettings.h" +#include "Kismet/GameplayStatics.h" void UOptionsUIWidget::NativeConstruct() { @@ -69,6 +71,14 @@ void UOptionsUIWidget::NativeConstruct() { ResetToDefaultsButton->OnClicked.AddUniqueDynamic(this, &UOptionsUIWidget::ResetToDefaultsButtonOnClicked); } + + if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + UWidgetBlueprintLibrary::SetInputMode_UIOnlyEx(PlayerController, this, EMouseLockMode::LockAlways); + PlayerController->bShowMouseCursor = true; + } + + SetIsFocusable(true); } void UOptionsUIWidget::SetReturnScreen(UUserWidget* userWidget)