I'm new to Unity and trying to create a Carrom game. Since all the White and Black pieces, Queen basically have the same material and physical properties and texture except for their color, I'm trying to create a single material that I could assign to all 3 types of objects but could then set the material color per object type. Can this be achieved in Unity (I'm using 5.3.2)?
MaterialPropertyBlock probably what you are looking for. Just make sure to create the block once and cache it, to save on garbage collection.
I'd create one
MaterialPropertyBlock per piece color (so a red and a black, with the material by itself being white), cache them, and apply the block to each piece as needed.
In a simple case you can change the main albedo color of the material of an object by assigning a different Color to
Note that some advanced materials have multiple color properties which serve different purposes. In that case
Material.color might not be the color you actually want to change and you have to use the
material.SetColor(propertyName, color) method.
Also, in some cases a renderer can use more than one material. In that case
renderer.material will be the first material. When that is not the one you want to change, you can find the other materials in the
By the way: Changing the color of the material of an object at runtime causes an entirely new material to be created. So when you have a large number of colored objects in your game but only a small number of different colors, it might be far more efficient to have a small number of different materials and assign these to the objects (as in Hamaz Hasan's answer) or use a MaterialPropertyBlock (as in the answer by Draco18s).
Actually normally people get benefit and consider it as a feature of Unity. For example, in Carrom you'd probably have to have 3 colors (Black, White and Red). What you have to do is to create 3 Materials for the above colors and apply at all 3 types of object. So from that you can change a single color from material and all the objects would change their color having this material attached.
Although you can set same physical properties to all the objects.