I have a button in a widget that when clicked changes the material of a single static mesh to a prescribed material and then back again to its original. I have a function that does this and this function works:
However, I also have scenes that have some static meshes under them. When I click the button, I want all static meshes under that scene to change to the same prescribed material and then back again when clicked again. Even worse: some static meshes have multiple materials, which all need to be set to a prescribed material (hence I need to loop through the materials as well).
This also works. The problem however is that right now I’m using a boolean that flips everytime the button is clicked, which handles the branch to be True or False. This is a function that I want to use for multiple buttons with different secnes (which is why the scene is given as input). If I now click Button 1 and the mesh changes, that would mean that the boolean is flipped so when I click Button 2 nothing really happens, only on the second click. Imagine this with more than just two buttons.
One option I have is to give the boolean as input as well, but then I get quite some boolean variables, so I try to avoid that. Also, the function for the single static mesh does work without a boolean.
The other option is to compare the current material with the default material and determine True/False based on that. I wrote the following for that:
This does not work: it’s never True. Hence something is wrong in the material comparison but I’m not sure what it is. I know the materials are objects, so if I’m right that means that the object references are never the same. This would be a more suitable solution to the problem I think.
Does anyone know what I’m missing here?