public void Create(VertexGenerator vg, Vector3 origin) { //Track the angle we are currenlty on TerrainAngle = vg.CurrentTerrainRule.Angle; //Create the front mesh and populate our key verts for the front plane MeshPiece mp = new MeshPiece(vg, MeshPiece.Plane.Front, settings); mp.PopulateKeyVerticies(MeshPiece.Plane.Front); //Now create the mesh mp.Create(origin, TerrainAngle); //The first mesh could be null if we are below the minimum verticies we need to create a plane if (mp.MeshObject != null) { //Create a placeholder object for our mesh pieces InstantiateTerrainObject(); //if (meshCollider == null) { // meshCollider = TerrainObject.AddComponent<MeshCollider>(); // meshCollider.convex = true; //} if (terrainCollider == null) { terrainCollider = TerrainObject.AddComponent <TerrainCollider>(); terrainCollider.material = new PhysicMaterial(); } //And add the front plane mesh piece to our list of meshes in the terrain piece MeshPieces.Add(mp); if (settings.DrawDetailMeshRenderer) { MeshPiece mpDetail = new MeshPiece(vg, MeshPiece.Plane.Detail, settings); mpDetail.Create(origin + settings.DetailPlaneOffset, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpDetail); } if (settings.DrawTopMeshCollider || settings.DrawTopMeshRenderer) { MeshPiece mpTop = new MeshPiece(vg, MeshPiece.Plane.Top, settings); mpTop.Create(mp.StartTopMesh, TerrainAngle, mp.KeyTopVerticies); MeshPieces.Add(mpTop); } //Just to tidy up the heirarchy ParentMeshesToTerrainObject(); } }