Change materials at runtime

Hello! Basically, i have many objects with material called #Base. At runtime, if i click on a button, is it possible to make it so the #Base material gets replaced by material called #Black or something? Keep in mind, each object has #Base, #DarkMetal,#Lights and other materials, but i only need to change #Base (Basically paintjob for a vehicle)

well you could make a list of materials, and when needed asign them to your remderer.

//for example

getcomponent<renderer>().material = mymaterials[yourvalue];