public static void ExportTerrain() { if (!SetupSave()) { return; } if (GameObject.FindObjectsOfType <Terrain>().Length > 1) { Debug.LogError("More than 1 terrain in scene"); return; } var terrain = GameObject.FindObjectOfType <Terrain>(); var terrainExtention = terrain.gameObject.GetComponent <TerrainExtension>(); if (terrainExtention == null) { Debug.LogError("Couldn't find terrain extention"); return; } TerrainMapGenerator.GenerateHeightMap(terrainExtention, GetPath(heightmapFilename)); TerrainMapGenerator.GenerateNormalMap(terrainExtention, GetPath(lightmapFilename)); TerrainMapGenerator.SaveSplatMapFromTerrain(terrainExtention, GetPath(splatmapFilename)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); TerrainExtension ter = (TerrainExtension)target as TerrainExtension; EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Editor for terrain extension"); EditorGUILayout.EndHorizontal(); /*if (ter.Lightmap != null) * { * if (GUILayout.Button("Generate NormalMap")) * { * if (ter.BakeAllTimeIndicesUpTo > 0) * { * for (int i = 0; i < ter.BakeAllTimeIndicesUpTo; i++) * { * ter.BakeTimeIndex = i; * TerrainMapGenerator.GenerateNormalMap(ter, AssetDatabase.GetAssetOrScenePath(ter.GetNormalMap())); * } * } * else * { * TerrainMapGenerator.GenerateNormalMap(ter, AssetDatabase.GetAssetOrScenePath(ter.GetNormalMap())); * } * } * * if (GUILayout.Button("Generate HeightMap")) * { * TerrainMapGenerator.GenerateHeightMap(ter, AssetDatabase.GetAssetOrScenePath(ter.GetHeightMap())); * } * * } * else * { * GUILayout.Label("Must create a png map (with correct settings)\n and associate it as Normal map on both the material\n and on the terrain extension"); * }*/ if (ter.GetSplatMap() != null) { if (GUILayout.Button("Set splat from map")) { SetSplatFromMap(ter); } if (GUILayout.Button("Save splatmap")) { TerrainMapGenerator.SaveSplatMapFromTerrain(ter, AssetDatabase.GetAssetOrScenePath(ter.GetSplatMap())); } } if (GUILayout.Button("Generate splatmap from terrain")) { TerrainMapGenerator.GenerateSplatMap(ter); } if (GUILayout.Button("Smooth terrain")) { SmoothTerrain(ter); } /*if (GUILayout.Button("AddRockNoise")) * { * TerrainMapGenerator.GenerateRockNoise(ter); * }*/ }