private void Editor_CreateHistory(GTexturePainterArgs args) { if (!Editor_EnableHistory) { return; } if (EditedTerrains.Count == 0) { return; } List <GTerrainResourceFlag> flags = new List <GTerrainResourceFlag>(); flags.AddRange(ActivePainter.GetResourceFlagForHistory(args)); List <GStylizedTerrain> terrainList = new List <GStylizedTerrain>(EditedTerrains); string backupName = GBackup.TryCreateBackup(ActivePainter.HistoryPrefix, terrainList[0], flags, false); if (!string.IsNullOrEmpty(backupName)) { for (int i = 1; i < terrainList.Count; ++i) { GBackup.BackupTerrain(terrainList[i], backupName, flags); } } }
private void DoImport() { if (DesTerrain != null) { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, DesTerrain, GCommon.AllResourceFlags); } GUnityTerrainDataImporter importer = new GUnityTerrainDataImporter(); importer.SrcTerrain = SrcTerrain; importer.SrcData = SrcData; importer.DesData = DesData; importer.DesTerrain = DesTerrain; importer.ImportGeometry = ImportGeometry; importer.UseUnityTerrainSize = UseUnityTerrainSize; importer.ImportSplats = ImportSplats; importer.ImportSplatsAsAlbedo = ImportSplatsAsAlbedo; importer.CreateNewSplatPrototypesGroup = CreateNewSplatPrototypesGroup; importer.ImportTrees = ImportTrees; importer.CreateNewTreePrototypesGroup = CreateNewTreePrototypesGroup; importer.ImportGrasses = ImportGrasses; importer.CreateNewGrassPrototypesGroup = CreateNewGrassPrototypesGroup; importer.GrassDensity = GrassDensity; importer.Import(); if (DesTerrain != null) { GBackup.TryCreateBackup(HISTORY_PREFIX, DesTerrain, GCommon.AllResourceFlags); } }
private void Editor_CreateHistory(GTexturePainterArgs args) { if (!Editor_EnableHistory) { return; } List <GTerrainResourceFlag> flags = new List <GTerrainResourceFlag>(); flags.AddRange(ActivePainter.GetResourceFlagForHistory(args)); GBackup.TryCreateBackup(ActivePainter.HistoryPrefix, GroupId, flags, false); }
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 CreateAfterStampBackup() { string historyPrefix = instance.Channel == GTextureStampChannel.AlbedoMetallicSmoothness ? HISTORY_PREFIX_COLOR : instance.Channel == GTextureStampChannel.Splat ? HISTORY_PREFIX_TEXTURE : "Unknown Action"; List <GTerrainResourceFlag> resourcesFlag = new List <GTerrainResourceFlag>(); if (instance.Channel == GTextureStampChannel.AlbedoMetallicSmoothness) { resourcesFlag.Add(GTerrainResourceFlag.AlbedoMap); resourcesFlag.Add(GTerrainResourceFlag.MetallicMap); } else if (instance.Channel == GTextureStampChannel.Splat) { resourcesFlag.Add(GTerrainResourceFlag.SplatControlMaps); } GBackup.TryCreateBackup(historyPrefix, instance.GroupId, resourcesFlag); }
private void CreateBackupAfterApplyPath() { string historyPrefix = instance.Channel == GPathPainter.PaintChannel.AlbedoAndMetallic ? HISTORY_PREFIX_ALBEDO_METALLIC : instance.Channel == GPathPainter.PaintChannel.Splat ? HISTORY_PREFIX_SPLAT : "Unknown Action"; List <GTerrainResourceFlag> resourceFlag = new List <GTerrainResourceFlag>(); if (instance.Channel == GPathPainter.PaintChannel.AlbedoAndMetallic) { resourceFlag.Add(GTerrainResourceFlag.AlbedoMap); resourceFlag.Add(GTerrainResourceFlag.MetallicMap); } else if (instance.Channel == GPathPainter.PaintChannel.Splat) { resourceFlag.Add(GTerrainResourceFlag.SplatControlMaps); } GBackup.TryCreateBackup(historyPrefix, instance.SplineCreator.GroupId, resourceFlag); }
private void DoBulkImport() { string ext = BitDepth == GBitDepth.Bit8 ? "raw" : "r16"; List <string> files = new List <string>(Directory.GetFiles(DataDirectory)); files.RemoveAll(f => !f.EndsWith(ext)); GCommon.ForEachTerrain( BulkImportGroupId, (t) => { if (t == null || t.TerrainData == null) { return; } string file = files.Find( s => { string f = Path.GetFileNameWithoutExtension(s); return(f.StartsWith(BitDepth == GBitDepth.Bit8 ? "RAW8" : "RAW16") && f.EndsWith(t.TerrainData.Id)); }); if (string.IsNullOrEmpty(file)) { return; } GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.HeightMapAndFoliageResourceFlags); GRawImporter importer = new GRawImporter(); importer.Terrain = t; importer.DesData = t.TerrainData; importer.BitDepth = BitDepth; importer.UseRawResolution = UseRawResolution; importer.FilePath = file; importer.Import(); GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.HeightMapAndFoliageResourceFlags); }); GStylizedTerrain.MatchEdges(BulkImportGroupId); }
private void DoImport() { if (Terrain != null) { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, Terrain, GCommon.HeightMapAndFoliageResourceFlags); } GRawImporter importer = new GRawImporter(); importer.Terrain = Terrain; importer.DesData = DesData; importer.BitDepth = BitDepth; importer.UseRawResolution = UseRawResolution; importer.FilePath = FilePath; importer.Import(); if (Terrain != null) { GBackup.TryCreateBackup(HISTORY_PREFIX, Terrain, GCommon.HeightMapAndFoliageResourceFlags); } }
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); } }
private void CreateAfterStampBackup() { GBackup.TryCreateBackup(HISTORY_PREFIX, instance.GroupId, GCommon.FoliageInstancesResourceFlags); }
private void DoBulkImport() { string[] guid = AssetDatabase.FindAssets("t:TerrainData", new string[] { Directory }); List <TerrainData> terrainDatas = new List <TerrainData>(); for (int i = 0; i < guid.Length; ++i) { string path = AssetDatabase.GUIDToAssetPath(guid[i]); TerrainData data = AssetDatabase.LoadAssetAtPath <TerrainData>(path); terrainDatas.Add(data); } GCommon.ForEachTerrain( BulkImportGroupId, (t) => { if (t == null || t.TerrainData == null) { return; } TerrainData srcData = terrainDatas.Find(d => d.name.StartsWith("TerrainData") && d.name.EndsWith(t.TerrainData.Id)); if (srcData == null) { return; } GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); GUnityTerrainDataImporter importer = new GUnityTerrainDataImporter(); importer.SrcTerrain = null; importer.SrcData = srcData; importer.DesData = t.TerrainData; importer.DesTerrain = t; importer.ImportGeometry = ImportGeometry; importer.UseUnityTerrainSize = UseUnityTerrainSize; importer.ImportSplats = ImportSplats; importer.ImportSplatsAsAlbedo = ImportSplatsAsAlbedo; bool createNewSplatGroup = CreateNewSplatPrototypesGroup; if (t.TerrainData.Shading.Splats == null || t.TerrainData.Shading.Splats == GGriffinSettings.Instance.TerrainDataDefault.Shading.Splats) { createNewSplatGroup = true; } importer.CreateNewSplatPrototypesGroup = createNewSplatGroup; importer.ImportTrees = ImportTrees; bool createNewTreeGroup = CreateNewTreePrototypesGroup; if (t.TerrainData.Foliage.Trees == null || t.TerrainData.Foliage.Trees == GGriffinSettings.Instance.TerrainDataDefault.Foliage.Trees) { createNewTreeGroup = true; } importer.CreateNewTreePrototypesGroup = createNewTreeGroup; importer.ImportGrasses = ImportGrasses; bool createNewGrassGroup = CreateNewGrassPrototypesGroup; if (t.TerrainData.Foliage.Grasses == null || t.TerrainData.Foliage.Grasses == GGriffinSettings.Instance.TerrainDataDefault.Foliage.Grasses) { createNewGrassGroup = true; } importer.CreateNewGrassPrototypesGroup = createNewGrassGroup; GrassDensity = GUnityTerrainDataImporter.GetAdjustedGrassDensity(srcData); importer.GrassDensity = GrassDensity; importer.Import(); GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); }); GStylizedTerrain.MatchEdges(BulkImportGroupId); }
private void CreateBackupAfterApplyRamp() { GBackup.TryCreateBackup(HISTORY_PREFIX, instance.SplineCreator.GroupId, GCommon.HeightMapAndFoliageResourceFlags); }
private void CreateBackupAfterApply() { GBackup.TryCreateBackup(HISTORY_PREFIX, instance.SplineCreator.GroupId, GCommon.FoliageInstancesResourceFlags); }