diff --git a/Source/Nakatomi/MainMenuUIWidget.cpp b/Source/Nakatomi/MainMenuUIWidget.cpp index c3c9176..b30b9f9 100644 --- a/Source/Nakatomi/MainMenuUIWidget.cpp +++ b/Source/Nakatomi/MainMenuUIWidget.cpp @@ -13,37 +13,45 @@ void UMainMenuUIWidget::NativeConstruct() if (NewGameButton) { NewGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::NewGameButtonOnClicked); + NewGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound); NewGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::NewGameTextBlockHoveredDelegate); NewGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::NewGameTextBlockUnhoveredDelegate); + NewGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayUnhoveredSound); } if (LoadGameButton) { LoadGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::LoadGameButtonOnClicked); + LoadGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound); LoadGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::LoadGameTextBlockHoveredDelegate); LoadGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::LoadGameTextBlockUnhoveredDelegate); + LoadGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayUnhoveredSound); } if (OptionsButton) { OptionsButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::OptionsButtonOnClicked); + OptionsButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound); OptionsButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::OptionsTextBlockHoveredDelegate); OptionsButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::OptionsTextBlockUnhoveredDelegate); + OptionsButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayUnhoveredSound); } if (QuitButton) { QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitButtonOnClicked); + QuitButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound); QuitButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitTextBlockHoveredDelegate); QuitButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitTextBlockUnhoveredDelegate); + QuitButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayUnhoveredSound); } if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0)) diff --git a/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp b/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp index cf45776..f80ff09 100644 --- a/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp +++ b/Source/Nakatomi/UI/NakatomiInteractiveWidget.cpp @@ -22,3 +22,11 @@ void UNakatomiInteractiveWidget::SetTextBlockUnhovered(UTextBlock* TextBlock) { TextBlock->SetColorAndOpacity(FSlateColor(ButtonUnhoveredTextColor)); } + +void UNakatomiInteractiveWidget::PlayUnhoveredSound() +{ + if (ButtonUnhoveredSound) + { + UGameplayStatics::PlaySound2D(GetWorld(), ButtonUnhoveredSound); + } +} diff --git a/Source/Nakatomi/UI/NakatomiInteractiveWidget.h b/Source/Nakatomi/UI/NakatomiInteractiveWidget.h index 4c0971c..2d6315b 100644 --- a/Source/Nakatomi/UI/NakatomiInteractiveWidget.h +++ b/Source/Nakatomi/UI/NakatomiInteractiveWidget.h @@ -26,6 +26,9 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) FLinearColor ButtonUnhoveredTextColor = {1, 1, 1, 1}; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + USoundBase* ButtonUnhoveredSound; + protected: UFUNCTION() void PlayHoveredSound(); @@ -35,5 +38,8 @@ protected: UFUNCTION() void SetTextBlockUnhovered(UTextBlock* TextBlock); + + UFUNCTION() + void PlayUnhoveredSound(); };