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)
|
if (ResumeButton)
|
||||||
{
|
{
|
||||||
ResumeButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ResumeButtonOnClicked);
|
ResumeButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ResumeButtonOnClicked);
|
||||||
|
ResumeButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OptionsButton)
|
if (OptionsButton)
|
||||||
{
|
{
|
||||||
OptionsButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::OptionsButtonOnClicked);
|
OptionsButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::OptionsButtonOnClicked);
|
||||||
|
OptionsButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SaveButton)
|
if (SaveButton)
|
||||||
{
|
{
|
||||||
SaveButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::SaveButtonOnClicked);
|
SaveButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::SaveButtonOnClicked);
|
||||||
|
SaveButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QuitButton)
|
if (QuitButton)
|
||||||
{
|
{
|
||||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::QuitButtonOnClicked);
|
QuitButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::QuitButtonOnClicked);
|
||||||
|
QuitButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExitGameButton)
|
if (ExitGameButton)
|
||||||
{
|
{
|
||||||
ExitGameButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ExitGameButtonOnClicked);
|
ExitGameButton->OnClicked.AddUniqueDynamic(this, &UPauseUIWidget::ExitGameButtonOnClicked);
|
||||||
|
ExitGameButton->OnHovered.AddUniqueDynamic(this, &UPauseUIWidget::PlayHoveredSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
|
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
|
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
||||||
FWindowsPlatformMisc::RequestExit(false);
|
FWindowsPlatformMisc::RequestExit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UPauseUIWidget::PlayHoveredSound()
|
||||||
|
{
|
||||||
|
if (ButtonHoveredSound)
|
||||||
|
{
|
||||||
|
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ public:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TSubclassOf<class UUserWidget> OptionsMenuWidget;
|
TSubclassOf<class UUserWidget> OptionsMenuWidget;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
USoundBase* ButtonHoveredSound;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UOptionsUIWidget* currentOptionsMenuWidget;
|
UOptionsUIWidget* currentOptionsMenuWidget;
|
||||||
|
|
||||||
|
@ -56,4 +59,7 @@ private:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void ExitGameButtonOnClicked();
|
void ExitGameButtonOnClicked();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void PlayHoveredSound();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue