Download

Further customization of UButton-derived widget?

So, I followed this tutorial for making a custom button and it worked great (and came together quickly!). Now I’m trying to get a feel for what further steps are worth the time to learn.

The goal of this would be to minimize the work that I have to do in the UI designer. However, my game will only ever have <15 buttons. Setting sizes, adding text widgets by hand, and keeping them up to date with changes would likely be faster than trying to deeply learn slate with the current amount of documentation.

The things I would like to do are:

  1. Set the default size of the button to the size of the images that I’m using.
  2. Add a text widget that is tied to a blueprint-exposed variable in the button.

So, are either of these things that I can do from my custom UButton or with light slate work, or would I need to get deep into it? I tried to scope it out myself, but after an hour of going through the UButton and SButton source code/documentation, I’m still having trouble finding what I’m looking for (Since I haven’t taken the time to learn slate yet).

If I remember correctly, you can’t add another widget to a widget deriving from UButton. You need to derive from UUserWidget and add a UButton and UText to it in overridden RebuildWidget method. You’ll also need to hook up the button events to your own events.

Sounds like that’s out of scope for me, what about setting the default button size?

Out of curiosity, how would you access the button’s events to hook them up to another class’ functions? Edit: Nvm, just found dispatchers