Change Texture of Material

I’m drawing a blank right now. I have a material applied to a bunch of different objects in my scene. I want to press a button and a texture of that material changes to a different texture. What is the best way to go about doing this?

You can use the dynamic material instances for that.

To make this work, you need to set your texture inside your material to Texture Sample Parameter 2D (you can do this by e.g. right-clicking your texture node and choosing Convert to Parameter). Name it however you want.

There is a Create Dynamic Material Instance function - as a Parent you set your base material. Then from the output of this function you can call the Set Texture Parameter Value function to specify a new texture on that material. Use the previously specified parameter name here.

The rest depends on your scene setup, blueprint setup, etc. Basically you need to create the dynamic material instance and apply it to your meshes that you want to change. Then use reference to this dynamic material to call the SetTextureParameterValue functions to change the texture. You can do it in your Level Blueprint as a quick test.

I also found some additional info on that here and here.

1 Like