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