Switching materials to a static mesh and then restore the original ones

Hi everyone
I’m actually working on an archviz project and i want to have some kind of x ray tool like the one you have in “CollabView” default project.
I tried to understand all the blueprints stored in that one but, in the end, my brain gave up lol, and i decided to try recreate something similar from scratch.
I need a simple system where you can point a mesh, click on it, override all the materials to an “x ray mat” i set up, and then on the second LMB click it restore the original materials applied to the mesh (i have several meshes that have more than 1 material so i need to store the data of every material applied in some way)

Here are some screenshot from my actual nodes mess (actually my node setup is capable of change the material index0 to the x ray one, but i need the possibility to “undo” that on the second click and have my old mats back)

Sorry for noobism and bad english :')
Thanks in advice to anyone who will help me out


Perhaps this might interest you. The material interpolate node.

seems like an interesting one but i think i need materials to be instances of the same parent… not my situation i think
But i will give it a try

Try this:

  1. Create the structure:

image

Materials: MaterialInterface array

  1. Add the variable:

image

Map: Key = StaticMeshActor, Value = struct array

  1. Create the function:

  1. Use the function:

I hope it’ll be helpful to you.

My Products

1 Like

hey man! thanks for the reply.
I’m trying out your solution: i just have a question: what is the input pin on the “switch material” function?
Cause what ever i try i can not connect that static mesh component node

1 Like

Last question (i hope so)
I don’t undestand where that “materials” array come from in the bottom of the screenshot
Immagine 2023-01-04 152945

image

image

1 Like

Man, you are officially the man of the day! Thank you so much!!!

Another problem incoming
Everything worked fine on a test project but, as soon as i migrated everything inside the main project file, the pointer turn my materials into the desired material, but on the second click the mesh have the default material grid (no mat)
Any clue why is doing it?

update, it seems like on some objects it work fine, on some others it apply the material grid

I’ve made a mistake.
Add Not node here:

Now it’s perfect!!!
Do you know why this generate some issues if my xray material is translucent?
With opaque material everything is perfect but as soon as i do an xray translucent material (to low opacity) the switch mat turns it material grid

I have no idea. I can’t debug this without any data.

First, check your translucent material in the level editor.
If it’s OK, create a test to check it at runtime:

If the issue is reproduced with these checks, it would be better to create a new topic for this.

i made BP like you said and it is really great but i got nothing when i placed on my scene !