UMG Events Depending on Button Sequence

Hello all,

I’ve been playing around with the UMG functions and I would like to implement a certain function I’ve been trying to solve but to no avail.

In my UMG, I have two buttons which I intent to select different classes of meshes in my world.

Then, I have separate buttons to adjust the materials/colors of each mesh.

And this is how I’m changing the materials of the StaticMeshActors in my level.

With these blueprints, I would like to change the material of the selected mesh from the button but after selecting the cylinder and changing its color to blue, it will change both meshes’ colors to blue and the subsequent colors will end up being the same.

I’ve tried using boolean functions to check if one has been clicked to deselect the other one but it seems like a very inefficient way to do these simple things.

If anyone could point me to the correct direction (preferably with Event Dispatchers since I’m trying to learn it), that would be really great.

Thanks!

Update:

After taking a coffee break, I’ve managed to do it in a very unconventional (and inefficient) way.

I’m still curious on how this can be done in a more efficient way so if anyone could share how this would be implemented, that would be real nice!

One more extendable method you might try is to generalize your array more. For example, you have cubes and cylinders, right? Maybe make a parent class called “Shapes” and let cubes and cylinders inherit from that. Then you can store all the cubes or all the cylinders in a “Shapes” array and simply change the color of all those stored shapes (which will be either cubes or cylinders, but not both) on key press.