private static void Export()
        {
            EditorUtility.DisplayProgressBar("Exporting", "Exporting terrain to file...", 1f);
            try
            {
                List <Mesh>         meshes      = new List <Mesh>();
                TerrainToFileConfig config      = TerrainToFileConfig.Instance;
                GStylizedTerrain    terrain     = config.Terrain;
                GTerrainData        terrainData = terrain.TerrainData;
                int gridSize = terrainData.Geometry.ChunkGridSize;
                int lod      = config.LOD;

                GTerrainChunk[] chunks = terrain.GetComponentsInChildren <GTerrainChunk>();
                for (int i = 0; i < chunks.Length; ++i)
                {
                    Mesh m = chunks[i].MeshFilterComponent.sharedMesh;
                    if (m != null)
                    {
                        Mesh      cloneMesh      = Object.Instantiate(m);
                        Matrix4x4 chunkToWorld   = chunks[i].transform.localToWorldMatrix;
                        Matrix4x4 worldToTerrain = terrain.transform.worldToLocalMatrix;
                        Matrix4x4 matrix         = chunkToWorld * worldToTerrain;
                        TransformMesh(cloneMesh, matrix);
                        meshes.Add(cloneMesh);
                    }
                }

                string fileName = string.Format("{0}_{1}_{2}",
                                                config.Terrain.name.Replace(" ", "_"),
                                                config.Terrain.GetInstanceID().ToString(),
                                                "LOD" + config.LOD);

                GUtilities.EnsureDirectoryExists(config.Directory);
                string filePath = null;
                if (config.FileType == MeshSaver.FileType.Obj)
                {
                    filePath = MeshSaver.SaveObjMultipleMesh(meshes.ToArray(), config.Directory, fileName);
                }
                else if (config.FileType == MeshSaver.FileType.Fbx)
                {
                    filePath = MeshSaver.SaveFbxMultipleMesh(meshes.ToArray(), config.Directory, fileName);
                }

                for (int i = 0; i < meshes.Count; ++i)
                {
                    Object.DestroyImmediate(meshes[i]);
                }

                AssetDatabase.Refresh();

                if (!string.IsNullOrEmpty(filePath))
                {
                    string        assetPath = filePath;
                    ModelImporter importer  = ModelImporter.GetAtPath(assetPath) as ModelImporter;
                    if (importer != null)
                    {
                        importer.useFileScale = false;
                        importer.weldVertices = false;
                        importer.SaveAndReimport();
                    }

                    Object asset = AssetDatabase.LoadAssetAtPath <Object>(assetPath);
                    if (asset != null)
                    {
                        Selection.activeObject = asset;
                        EditorGUIUtility.PingObject(asset);
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
            }

            EditorUtility.ClearProgressBar();
        }