Using one material for multiple textures

I am creating a game where I would like to apply a color scheme to each player’s units. The way I am currently doing this is to have a single material that is applied to all units. The problem I’m running into is changing the textures when it is time to draw a different unit. Is there an easy way to do this besides making a separate material for each unit?

Look up Material in the scripting reference (top search on “Unity Material”.) You can set the mainTexture property (it has an example.)

But, there’s good chance you may want to have a material for each color. Suppose one of the colors is shiny gold. You might want a specular shader for that, with certain settings. A tree-bark “color” may want a bump-map shader, with the extra bump-map texture. Might be better to Edit->Duplicate materials, even though most are only a texture change. Then swap materials instead of just textures.