public override void OnInspectorGUI() { if (t2m == null) { t2m = (TerrainToMesh)target; } //if (!TerrainToMesh.terrain) //{ // GUILayout.Label("No terrain found"); // //if (GUILayout.Button("Cancel")) // //{ // // //EditorWindow.GetWindow<ExportTerrain>().Close(); // //} // return; //} if (t2m.GetComponent <Terrain>() != null) { TerrainToMesh.terrain = t2m.GetComponent <Terrain>().terrainData; } t2m.saveFormat = (SaveFormat)EditorGUILayout.EnumPopup("Export Format", t2m.saveFormat); t2m.saveResolution = (SaveResolution)EditorGUILayout.EnumPopup("Resolution", t2m.saveResolution); if (GUILayout.Button("Export")) { t2m.fileName = EditorUtility.SaveFilePanel("Export .obj file", "", "Terrain", "obj"); t2m.Export(); } }
private void OnGUI() { GUILayout.Label("Base Settings", EditorStyles.boldLabel); meshName = EditorGUILayout.TextField("Mesh Name", meshName); //path = EditorGUILayout.TextField("Path for mesh", path); sampleSize = EditorGUILayout.IntField("Number of squares in row:", sampleSize); meshWidth = EditorGUILayout.IntField("Width of the mesh:", meshWidth); lowestPointToZero = EditorGUILayout.Toggle("Lowest point to 0", lowestPointToZero); data = (TerrainData)EditorGUILayout.ObjectField(data, typeof(TerrainData), true); if (GUILayout.Button("Generate Mesh")) { mesh = TerrainToMesh.CreateMeshFromTerrainData(sampleSize, meshWidth, data, lowestPointToZero); string assetPath = path + meshName; TerrainToMesh.CreateMesh(mesh, meshName); } }