Add OnHovered Sound2D in PauseMenuUIWidget
This commit is contained in:
parent
16efcc8fd7
commit
2fb940610c
BIN
Content/UI/Pause/PauseMenu.uasset (Stored with Git LFS)
BIN
Content/UI/Pause/PauseMenu.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -14,26 +14,31 @@ void UPauseUIWidget::NativeConstruct()
|
|||
if (ResumeButton)
|
||||
{
|
||||
ResumeButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ResumeButtonOnClicked);
|
||||
ResumeButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||
}
|
||||
|
||||
if (OptionsButton)
|
||||
{
|
||||
OptionsButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::OptionsButtonOnClicked);
|
||||
OptionsButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||
}
|
||||
|
||||
if (SaveButton)
|
||||
{
|
||||
SaveButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::SaveButtonOnClicked);
|
||||
SaveButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||
}
|
||||
|
||||
if (QuitButton)
|
||||
{
|
||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::QuitButtonOnClicked);
|
||||
QuitButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||
}
|
||||
|
||||
if (ExitGameButton)
|
||||
{
|
||||
ExitGameButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ExitGameButtonOnClicked);
|
||||
ExitGameButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||
}
|
||||
|
||||
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
|
||||
|
@ -87,3 +92,11 @@ void UPauseUIWidget::ExitGameButtonOnClicked()
|
|||
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
||||
FWindowsPlatformMisc::RequestExit(false);
|
||||
}
|
||||
|
||||
void UPauseUIWidget::PlayHoveredSound()
|
||||
{
|
||||
if (ButtonHoveredSound)
|
||||
{
|
||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ public:
|
|||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<class UUserWidget> OptionsMenuWidget;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USoundBase* ButtonHoveredSound;
|
||||
|
||||
private:
|
||||
UOptionsUIWidget* currentOptionsMenuWidget;
|
||||
|
||||
|
@ -56,4 +59,7 @@ private:
|
|||
|
||||
UFUNCTION()
|
||||
void ExitGameButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void PlayHoveredSound();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue