/// <summary> /// Construct the mesh for each defined region. /// </summary> void GenerateMesh() { _altitude = new Altitude(); foreach (Region region in _regions) { float elevation = 0; region.ConstructMesh(out elevation); _altitude.Evaluate(elevation); } foreach (Transform child in transform) { child.GetComponent <MeshRenderer>().sharedMaterial.SetFloat("minHeight", _altitude.MinAltitude); child.GetComponent <MeshRenderer>().sharedMaterial.SetFloat("maxHeight", _altitude.MaxAltitude); child.GetComponent <MeshRenderer>().sharedMaterial.SetTexture("_MainTex", TextureUtils.TextureFromGradient(PlanetSettings.ColorSettings.Gradient)); } }