Applying Materials With a script

Does anyone know how to write a script that will allow me to apply a material to a mesh when I hit a button or something?

Check this out

To change the material on a mesh renderer:

var meshRenderer = componentOrGameObject.GetComponent<MeshRenderer>();
if( meshRenderer )
    meshRenderer.sharedMaterial = newMaterialToChangeTo;

you could also use componentOrGameObject.renderer but if you have a particle renderer or trail renderer as well you might get one of those instead. And you should check if its non null unless your sure.

using .material instead of .sharedMaterial may make a copy of the material you set as well ( which you may or may not want )