In BP, how to restore the materials that were set in editor, as opposed to materials set in mesh?
Say I import a mesh, and in the mesh editor it uses "Black" material. Then I put this mesh into the model, and set the material on the actor to "White". Then I make this mesh into a blueprint, and make a boolean to switch the material to a third material, "Green".
I've tried a few methods, but cannot get the material to revert to "White" when required. Instead, it reverts to "Black".
When the switch is active, I have attempted to directly set the "Green" material. I have also attempted to create and set a Dynamic Material Instance using the "Green" material as the parent. Either method changes the material as required.
When the switch is turned off, I cannot get the "White" material restored. If I use Set Material and leave the material pin empty (ie None), it reverts to the meshes default material, ie "Black". I want it to revert to "White", the material set in the editor. I have attempted to save the original materials to a variable using the construction script, but it saves the "Green" material if the dynamic material instance is the active material when the construction script runs.
In this use-case, changing the material of the static mesh asset is not practical, as there are hundreds that import with a default material. Also, I may not want each actor using the asset to have the same material. Lastly, I want the materials to be completely independent, not already being material instances themselves.
How can I fix this?
Here's what I came up with to cache the materials. This allows the material to be set to a different material from within the editor, even if the temporary material is the active material.
answered Jan 31 '19 at 05:50 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here