Hey Guys!
You must have answered several of these questions, but all I want to know is how to make a material on a duplicated object change itself to another material which is on the original object. I am using a script to make a city with buildings of random heights. Here is a code snippet pertaining to setting the sharedMaterial.
for(int x = 0; x < BuildingHeight; x++)
{
var Cube = Instantiate(BuildingTransform) as GameObject;
Cube.transform.position = new Vector3(BuildingPos.x, BuildingPos.y + BuildingScale.y * x * 2 , BuildingPos.z);
Cube.isStatic = true;
// Cube.rigidbody.isKinematic = false;
Cube.tag = "Building";
Cube.transform.parent = transform;
Cube.renderer.sharedMaterial = BuildingTransform.renderer.sharedMaterial;
}
The materials of the others don’t change when I change the material of the building transform object. I just need to know if I’m setting the shared material correctly? Can anyone tell me how to implement it for a simple duplicate operation and then for this script? Does sharedMesh come into play here?
Thanks.