private void DoBulkImport() { string[] guid = AssetDatabase.FindAssets("t:Texture2D", new string[] { Directory }); List <Texture2D> textures = new List <Texture2D>(); for (int i = 0; i < guid.Length; ++i) { string path = AssetDatabase.GUIDToAssetPath(guid[i]); Texture2D tex = AssetDatabase.LoadAssetAtPath <Texture2D>(path); textures.Add(tex); } GCommon.ForEachTerrain( BulkImportGroupId, (t) => { if (t == null || t.TerrainData == null) { return; } GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); Texture2D hm = textures.Find(tex => tex.name.StartsWith("HeightMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D mkm = textures.Find(tex => tex.name.StartsWith("MaskMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D vm = textures.Find(tex => tex.name.StartsWith("VisibilityMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D am = textures.Find(tex => tex.name.StartsWith("AlbedoMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D mm = textures.Find(tex => tex.name.StartsWith("MetallicMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D[] cm = new Texture2D[t.TerrainData.Shading.SplatControlMapCount]; for (int i = 0; i < cm.Length; ++i) { cm[i] = textures.Find(tex => tex.name.StartsWith("ControlMap" + i.ToString()) && tex.name.EndsWith(t.TerrainData.Id)); } GTextureImporter importer = new GTextureImporter(); importer.Terrain = t; importer.DesData = t.TerrainData; importer.HeightMap = hm; importer.MaskMap = mkm; importer.VisibilityMap = vm; importer.AlbedoMap = am; importer.MetallicMap = mm; importer.SplatControlMaps = cm; importer.Import(); GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); }); GStylizedTerrain.MatchEdges(BulkImportGroupId); }
private void DoImport() { if (Terrain != null) { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, Terrain, GCommon.AllResourceFlags); } GTextureImporter importer = new GTextureImporter(); importer.Terrain = Terrain; importer.DesData = DesData; importer.HeightMap = HeightMap; importer.VisibilityMap = VisibilityMap; importer.AlbedoMap = AlbedoMap; importer.MetallicMap = MetallicMap; importer.SplatControlMaps = SplatControlMaps; importer.Import(); if (Terrain != null) { GBackup.TryCreateBackup(HISTORY_PREFIX, Terrain, GCommon.AllResourceFlags); } }