Slate Style - FSlateSound - How to create it to set it in FButtonStyle PressedSound property

Hi,

I can’t find any example on how to create properly a FSlateSound to set in PressedSound of a button.

All the samples that I found are:
FSlateSound::FromName_DEPRECATED(FName(“SoundCue’/Game/UI/Sounds/…”));

But as the name of the function said, it’s Deprecated.
I bet I have to call “SetResourceObject” with a USoundBase but i’m not confident this is it and I don’t want to load all my UI Sound when creating my style.
it’s not required until it’s used (what the old method do).

More usually in a Deprecated function, Epic said what should be used instead but here no hint have been provided. Even Slate Base code is using this deprecated function.

Thanks,

In case some newbie like me search for answers after 9 years, to set batch of buttons pressed sound in a UserWidget panel by c++;
create a USoundCue * press_sound; in mainUserWidget.h , (need to be Blueprint access by UPROPERTY(EditAnywhere)
To set this resource to FSlateSound, in .cpp,
… get child userwidgets in the main panel widgets, … and…
FSlateSound ss;
if (IsValid(press_sound))
{
ss.SetResourceObject(press_sound);
}
for (auto& ub : uwg_get)
{ // ub* is the UWidget* get from main canvas panel…
if (ub->IsA(UButton::StaticClass()))
{
FButtonStyle bns = Cast(ub)->WidgetStyle;
bns.SetPressedSound(ss);
Cast(ub)->SetStyle(bns);
}
}


BTW, don’f forget to add “SlateCore” to YourProject.Build.cs, otherwise linking errors.