private void Compile(InputBuildContext context) { context.info.compilerCount++; InputGeometryCompiler compiler = context.geomCompiler; List <Component> items = context.components; List <byte> areas = context.areas; for (int i = 0; i < items.Count; i++) { Component item = items[i]; if (item is Terrain) { Terrain terrain = (Terrain)item; if (terrain.terrainData != terrainData) { continue; } TriangleMesh mesh = TerrainUtil.TriangulateSurface(terrain, mResolution); byte[] lareas = NMGen.CreateAreaBuffer(mesh.triCount, areas[i]); if (compiler.AddTriangles(mesh, lareas)) { string msg = string.Format("Compiled the {0} terrain surface. Triangles: {1}" , terrain.name, mesh.triCount); context.Log(msg, this); } else { string msg = string.Format("Compiler rejected mesh for the {0} terrain.", terrain.name); context.LogError(msg, this); return; } if (includeTrees) { int before = compiler.TriCount; TerrainUtil.TriangluateTrees(terrain, areas[i], compiler); string msg = string.Format("Compiled the {0} terrain trees. Triangles: {1}" , terrain.name, compiler.TriCount - before); context.Log(msg, this); } break; } } }