How to change Button background based on state in Blueprints?

I know this question is not new, and I’ve read some solutions to my question. The problem is that I don’t know which one best fits to my needs…

I have a level selection menu in which I have a screen where all levels are shown with their corresopnding text and image. Like the example that follows here:

So there will be locked and unlocked levels. I’m following [this tutorial][2] to create all level selection stuff, but instead of changing background color, I would like to change the full background image. The thing is I want a locker to appear like the one on this image, instead of a text.

I was wondering if there should be an easy way to achieve that using blueprints. Any help will be really appreciated!

I imagine something like this would work. It would involve keeping your level buttons, level number images, and level locked booleans in parallel arrays. If you have structs that hold that data then it should be a similar process looking through the structs.

The variables I made were:

  • Level Buttons - array of button references
  • Levels Unlocked - array of booleans (obviously)
  • Number Textures - array of Texture 2D
  • Locked Texture - Texture 2D

I’m just thinking now you’ll probably want to use materials instead of textures, in which case just swap out your Texture 2D variables for Material ones, and use the “Set Brush Resource to Material” node. Just make sure that your materials are in the “User Interface” material domain.

Hummm Looks interesting… I’m gonna give it a try and I will let you know if it works for me!

I can’t get the “style” of the button… Could you please tell me which node are you looking for? I tried “Get style” but it’s a simple reference to the button style…

I found it. Your solution is simply PERFECT!!

Glad to hear

I’m also fancing a problem with button size… Now it’s as big as text inside… How can I make it be as big as I want? (resize it…)

I tried this till now:

Your buttons might have “fit size to content” set to true. If it is, turn it off.

On the Blueprint widget it’s set to false, but I can’t set it to false dynamically…