Here is my noobish scenario I'm trying to understand:
Some class, Terrain:
void Start()
{
...
switch (Type)
{
case TerrainType.StartPoint:
renderer.material.color = Color.blue;
break;
case TerrainType.EndPoint:
renderer.material.color = Color.red;
break;
case TerrainType.Wall:
renderer.material.color = Color.black;
break;
default:
renderer.material.color = Color.green;
break;
}
...
}
some other class, SomeOtherClass: ('target' is Terrain object)
void Awake()
{
...
temp = (Terrain) Instantiate(target, new Vector3(0,0,0), Quaternion.identity);
...
}
At this point everything is ok.
If, down the road, i try assigning different type to one of the existing Terrain objects, the type will change sure, but the color will not since color change switch is in Start()
If i put the color updating code in Update()
function sure it works and the color is changed but is this the right way of doing something like this?
I feel like it is an overkill since Update is called every frame and i might have only one or two calls to change the type throughout the whole game life time.