How can i save material in runtime?

Anyone please help! I have a project to make a simulation to change material on the wall of the house, for my thesis. I wanna save every wall that the material has been changed. I have not found the way to save it :frowning: your response will be meaningful to me. (sorry for bad grammar)