Add OnClicked Sound Functionality
This commit is contained in:
parent
2981ca4f79
commit
3bd680ca16
|
@ -13,6 +13,7 @@ void UMainMenuUIWidget::NativeConstruct()
|
|||
if (NewGameButton)
|
||||
{
|
||||
NewGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::NewGameButtonOnClicked);
|
||||
NewGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayClickedSound);
|
||||
|
||||
NewGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound);
|
||||
NewGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::NewGameTextBlockHoveredDelegate);
|
||||
|
@ -24,6 +25,7 @@ void UMainMenuUIWidget::NativeConstruct()
|
|||
if (LoadGameButton)
|
||||
{
|
||||
LoadGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::LoadGameButtonOnClicked);
|
||||
LoadGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayClickedSound);
|
||||
|
||||
LoadGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound);
|
||||
LoadGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::LoadGameTextBlockHoveredDelegate);
|
||||
|
@ -35,6 +37,7 @@ void UMainMenuUIWidget::NativeConstruct()
|
|||
if (OptionsButton)
|
||||
{
|
||||
OptionsButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::OptionsButtonOnClicked);
|
||||
OptionsButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayClickedSound);
|
||||
|
||||
OptionsButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound);
|
||||
OptionsButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::OptionsTextBlockHoveredDelegate);
|
||||
|
@ -46,6 +49,7 @@ void UMainMenuUIWidget::NativeConstruct()
|
|||
if (QuitButton)
|
||||
{
|
||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitButtonOnClicked);
|
||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayClickedSound);
|
||||
|
||||
QuitButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::PlayHoveredSound);
|
||||
QuitButton->OnHovered.AddUniqueDynamic(this, &UMainMenuUIWidget::QuitTextBlockHoveredDelegate);
|
||||
|
|
|
@ -30,3 +30,11 @@ void UNakatomiInteractiveWidget::PlayUnhoveredSound()
|
|||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonUnhoveredSound);
|
||||
}
|
||||
}
|
||||
|
||||
void UNakatomiInteractiveWidget::PlayClickedSound()
|
||||
{
|
||||
if (ButtonClickedSound)
|
||||
{
|
||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonUnhoveredSound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ public:
|
|||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USoundBase* ButtonUnhoveredSound;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
USoundBase* ButtonClickedSound;
|
||||
|
||||
protected:
|
||||
UFUNCTION()
|
||||
void PlayHoveredSound();
|
||||
|
@ -42,4 +45,7 @@ protected:
|
|||
UFUNCTION()
|
||||
void PlayUnhoveredSound();
|
||||
|
||||
UFUNCTION()
|
||||
void PlayClickedSound();
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue