private void SaveSettings() { // Get file path string path = EditorUtility.SaveFilePanel("Save Terrain Settings", "", "settings" + ".xml", "xml"); if (path.Length > 0) { // Get current splatmap tp_Containers.SettingsContainer c = new tp_Containers.SettingsContainer(); c.opacity = component.Opacity; c.strength = component.Strength; c.size = component.BrushSize; c.heights = new tp_Height[component.Heights.Count]; for (int i = 0; i < c.heights.Length; i++) { c.heights[i] = component.Heights[i]; } c.ramp = component.Ramp.Value; // Serialize and save splatmap string file = LoadSave.Serialize(c); StreamWriter writer = new StreamWriter(path); writer.Write(file); writer.Close(); // Print Debug.Log("Saving settings finished!"); } }
private void SaveSplatMap() { // Get file path string path = EditorUtility.SaveFilePanel("Save Terrain Splatmaps", "", "splatmap" + ".xml", "xml"); if (path.Length > 0) { // Get current time for determining how long it takes to save the splatmaps DateTime dt = DateTime.Now; // Get current splatmap tp_Containers.SplatmapContainer tc = new tp_Containers.SplatmapContainer(); tc.SetSplatmap(component.TerrainData.GetAlphamaps(0, 0, component.TerrainData.alphamapWidth, component.TerrainData.alphamapHeight)); // Serialize and save splatmap string file = LoadSave.Serialize(tc); StreamWriter writer = new StreamWriter(path); writer.Write(file); writer.Close(); // Print how long it took to save the splatmaps Debug.Log("Saving splatmap finished! time: [" + (DateTime.Now - dt).ToString() + "]"); } }