public void Build(Polygon polygon, float height) { // make a mesh var meshFilter = GetComponent<MeshFilter> (); var basement = polygon.Vertices.ToArray(); basement = ShiftBasement (basement, -polygon.center); meshFilter.mesh = MakeBuilding (basement, height); }
void BuildHouse(Polygon polygon) { if (!polygon.valid) return; var position = PositionOnTerrain(polygon.center); // intersection exists && position y is not minimal (not river) if (position != null && position.Value.y > 0.1) { // instantiate a new building GameObject b = Instantiate(buildingPrefab); b.transform.parent = cityLocation.transform; var builder = b.GetComponent<BuildingMesh>(); // build a building with specified parameters builder.Build(polygon, polygon.height); b.transform.position = position.Value; } }