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

**URL:** <https://forums.unrealengine.com/t/slate-style-fslatesound-how-to-create-it-to-set-it-in-fbuttonstyle-pressedsound-property/52102>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 11, 2016, 11:16am UTC](https://forums.unrealengine.com/t/slate-style-fslatesound-how-to-create-it-to-set-it-in-fbuttonstyle-pressedsound-property/52102 "2016-01-11T11:16:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elvince](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Elvince](https://forums.unrealengine.com/u/Elvince)\
**Post date:** [January 11, 2016, 11:16am UTC](https://forums.unrealengine.com/t/slate-style-fslatesound-how-to-create-it-to-set-it-in-fbuttonstyle-pressedsound-property/52102/1 "2016-01-11T11:16:56Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Lui.YK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lui.YK](https://forums.unrealengine.com/u/Lui.YK)\
**Post date:** [May 30, 2025, 6:55am UTC](https://forums.unrealengine.com/t/slate-style-fslatesound-how-to-create-it-to-set-it-in-fbuttonstyle-pressedsound-property/52102/2 "2025-05-30T06:55:34Z")

</div>

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.
