UI + change specific actors material

Hi all,

I am trying to implement a simple UI tool that highlights elements depending on metadata. I use checkboxes in my UI and depending on which checkbox is checked, certain actors change their material.

I am using checkbox to highlight/de-highlight specific actors. When one group is highlighted, I want all other ones to turn off – and my script does not seem to do that (see in the video), while the checkboxes change.

(this blueprint is for only one of the checkboxes, but they all are the same)
Sorry if the solution is obvious – I do not seem to find it, have been trying to fix it for a few days. Any tips would be appreciated!!

Hey, @alinator_bambie1!

A few questions:

  • From the snippet I can see so far your blueprint has a set variable is checked. Is your variable properly being changed when you click your different UI boxes?
  • If you used some debugging in your blueprints that used the Print String node that printed the current value of “Is Checked” for each type, are they returning the correct values when you switch between the types?

Here’s the documentation of the Print String node for more context, just make sure to have print to log set as true:

Unreal Engine Documentation: Print String

Any additional information you can provide on what blueprint handles your true and false states for your checks should help a lot!


hi @Quetzalcodename

Thank you so much for the tip. I did fix the set variables and now the check boxes work correctly.
However, while the checkboxes themselves work properly, the materials do not change the way it is intended.

I have several actors which have metadata component “office” as well as the metadata components for “a”, “b” and “c” classes. I need to be able to highlight all buildings with “a” class, “b” class, “c” class and “office’ type using UI checkboxes. When I press checkbox 'a” I need all other checkboxes be turned off, as well as the materials should go back to default white with the exception of the checked “a” class. For now the checkboxes in the widget can be checked one at a time (it is what I need), but the materials in the scene do not go back to the default one. (see in the video below)

About the debug, I added print and it seems to work only when I press a specific UI element, and they do not return correct values when I switch between the checkboxes.
I have a hypothesis that “On Checked State Changed” works only when the user clicks the check box, not when it’s changed through blueprint. So when the other boxes are unchecked through blueprint, the materials won’t change because the “On Checked State Changed” event is not being fired? If that’s the case, how do I circumvent that?

my new blueprint:

Please lte me know if you have any ideas or directions on how to resolve this. Thanks alot!!

Hey @alinator_bambie1!

I am assuming you have multiple widget blueprints working in tandem to get your checkboxes and color changes to work, correct?

Instead of setting the variable inside of the blueprint that changes the color, could you instead call a custom event in your blueprint that set’s your true and false values for each other blueprint to guarantee they are set in the correct locations? I’m not quite certain how you have each element set up, so some more clarity on that would be appreciated.

In the meantime, here is the official live training on Blueprint Communications that could also shed some light on one what is missing:

Blueprint Communications | Live Training | Unreal Engine

I hope the above solutions are what you need.

1 Like

Hi @Quetzalcodename

All checkboxes used are in the same blueprint, and the code is the same for all of them:

Should I have them in separate blueprints? It seems like a lot of nesting, just for individual checkboxes.
Thank you so much for your time!!

Hello again :stuck_out_tongue:
There’s nothing wrong with having the checkboxes in the same BP, but you definitely will need to cut down on that code repeating. As far as I can tell, all three events do the same thing except for which Check variable is set. Do you know how to use functions?

You could have something like this instead:

Where “Toggle Highlighted by String” contains all the nodes that you have in your screenshots. The string that is passed into the function is the one that gets compared to the Datasmith User Data Value. The material that is specified is the one you want the selected objects to be.

Also, the screenshots look like they have a lot of unnecessary and inconsistent nodes, I was able to cut it down to this (and move it inside the “Toggle Highlighted by String” function):

It’s pretty much the same as that last screenshot you had, except it uses the second branch instead of the first one when deciding whether to select or deselect the current Actor. To deselect the currently selected class by re-clicking the same checkbox, it just selects none of them.

Here is the result I’m getting, let me know if I misunderstood something or if you have any questions :slight_smile: