Skip to content

Commit 5475974

Browse files
committed
SaveMap ProgressBar
1 parent 10db3bb commit 5475974

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Assets/MapEditor/Managers/MapManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,18 @@ public static IEnumerator Save(string path)
757757
}
758758

759759
int progressID = Progress.Start("Save: " + path.Split('/').Last(), "Saving Map", Progress.Options.Sticky);
760+
int prefabID = Progress.Start("Prefabs", null, Progress.Options.Sticky, progressID);
761+
int pathID = Progress.Start("Paths", null, Progress.Options.Sticky, progressID);
762+
int terrainID = Progress.Start("Terrain", null, Progress.Options.Sticky, progressID);
760763

761764
SaveLayer();
762-
TerrainToWorld(Land, Water, progressID).Save(path);
763765
yield return null;
766+
TerrainToWorld(Land, Water, (prefabID, pathID, terrainID)).Save(path);
764767

768+
Progress.Report(progressID, 0.99f, "Saved");
769+
Progress.Finish(prefabID, Progress.Status.Succeeded);
770+
Progress.Finish(pathID, Progress.Status.Succeeded);
771+
Progress.Finish(terrainID, Progress.Status.Succeeded);
765772
Progress.Finish(progressID, Progress.Status.Succeeded);
766773
}
767774

Assets/MapEditor/Scripts/WorldConverter.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public static MapInfo EmptyMap(int size, float landHeight)
5555
Parallel.For(0, splatRes, i =>
5656
{
5757
for (int j = 0; j < splatRes; j++)
58-
{
5958
terrains.alphaMap[i, j] = true;
60-
}
6159
});
6260
terrains.topology = new TerrainMap<int>(new byte[(int)Mathf.Pow(splatRes, 2) * 4 * 1], 1);
6361
return terrains;
@@ -144,12 +142,8 @@ public static MapInfo WorldToTerrain(WorldSerialization world)
144142
}
145143

146144
/// <summary>Converts Unity terrains to WorldSerialization.</summary>
147-
public static WorldSerialization TerrainToWorld(Terrain land, Terrain water, int progressID)
145+
public static WorldSerialization TerrainToWorld(Terrain land, Terrain water, (int prefab, int path, int terrain) ID)
148146
{
149-
int prefabID = Progress.Start("Prefabs", null, Progress.Options.Sticky, progressID);
150-
int pathID = Progress.Start("Paths", null, Progress.Options.Sticky, progressID);
151-
int terrainID = Progress.Start("Terrain", null, Progress.Options.Sticky, progressID);
152-
153147
WorldSerialization world = new WorldSerialization();
154148
world.world.size = (uint) land.terrainData.size.x;
155149

@@ -208,8 +202,7 @@ public static WorldSerialization TerrainToWorld(Terrain land, Terrain water, int
208202
world.world.prefabs.Insert(0, p.prefabData);
209203
}
210204
}
211-
Progress.Report(prefabID, 0.99f, "Saved " + PrefabManager.CurrentMapPrefabs.Length + " prefabs.");
212-
Progress.Finish(prefabID, Progress.Status.Succeeded);
205+
Progress.Report(ID.prefab, 0.99f, "Saved " + PrefabManager.CurrentMapPrefabs.Length + " prefabs.");
213206

214207
foreach (PathDataHolder p in PathManager.CurrentMapPaths)
215208
{
@@ -224,15 +217,13 @@ public static WorldSerialization TerrainToWorld(Terrain land, Terrain water, int
224217
world.world.paths.Insert(0, p.pathData);
225218
}
226219
}
227-
Progress.Report(pathID, 0.99f, "Saved " + PathManager.CurrentMapPaths.Length + " paths.");
228-
Progress.Finish(pathID, Progress.Status.Succeeded);
220+
Progress.Report(ID.path, 0.99f, "Saved " + PathManager.CurrentMapPaths.Length + " paths.");
229221

230222
byte[] landHeightBytes = FloatArrayToByteArray(land.terrainData.GetHeights(0, 0, land.terrainData.heightmapResolution, land.terrainData.heightmapResolution));
231223
byte[] waterHeightBytes = FloatArrayToByteArray(water.terrainData.GetHeights(0, 0, water.terrainData.heightmapResolution, water.terrainData.heightmapResolution));
232224

233225
Task.WaitAll(splatTask, biomeTask, alphaTask, topologyTask);
234-
Progress.Report(terrainID, 0.99f, "Saved " + TerrainManager.TerrainSize.x + " size map.");
235-
Progress.Finish(terrainID, Progress.Status.Succeeded);
226+
Progress.Report(ID.terrain, 0.99f, "Saved " + TerrainSize.x + " size map.");
236227

237228
world.AddMap("terrain", landHeightBytes);
238229
world.AddMap("height", landHeightBytes);

0 commit comments

Comments
 (0)