Think of it as if it was a global variable that can be applied to many materials at once. Rather than replacing all materials and restoring them, you could use a single vector to change their look - turn them black, for example.
From the top of my head, I would create a structure, which contain a variable that can reference to an actor, and 1 variable that can contain a list of material template. Then before you switch all mesh material to a single material, go through all the mesh, create a structure for each mesh to store mesh reference and that mesh list of material, store it into an array of structure and put it somewhere that can be access later. Then when you want to restore all the material, just simple go through all the mesh and all the structure again, create and assign correct material to correct mesh.