// Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
// C # manual conversion work by Yun Kyu Choi
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.IO;
using System.Text;
enum SaveFormat { Triangles, Quads }
enum SaveResolution { Full=0, Half, Quarter, Eighth, Sixteenth }
class ExportTerrain : EditorWindow
{
SaveFormat saveFormat = SaveFormat.Triangles;
SaveResolution saveResolution = SaveResolution.Half;
static TerrainData terrain;
static Vector3 terrainPos;
int tCount;
int counter;
int totalCount;
int progressUpdateInterval = 10000;
[MenuItem("Terrain/Export To Obj...")]
static void Init()
{
terrain = null;
Terrain terrainObject = Selection.activeObject as Terrain;
if (!terrainObject)
{
terrainObject = Terrain.activeTerrain;
}
if (terrainObject)
{
terrain = terrainObject.terrainData;
terrainPos = terrainObject.transform.position;
}
EditorWindow.GetWindow<ExportTerrain>().Show();
}
void OnGUI()
{
if (!terrain)
{
GUILayout.Label("No terrain found");
if (GUILayout.Button("Cancel"))
{
EditorWindow.GetWindow<ExportTerrain>().Close();
}
return;
}
saveFormat = (SaveFormat) EditorGUILayout.EnumPopup("Export Format", saveFormat);
saveResolution = (SaveResolution) EditorGUILayout.EnumPopup("Resolution", saveResolution);
if (GUILayout.Button("Export"))