Ejemplo n.º 1
0
        private void LoadSettings()
        {
            // Get file path
            string path = EditorUtility.OpenFilePanel("Load Terrain Settings", "", "xml");

            if (path.Length > 0)
            {
                // Desirialize data
                StreamReader reader = new StreamReader(path);
                string       file   = reader.ReadToEnd();
                reader.Close();

                // Convert deserialized data to splatmaps
                tp_Containers.SettingsContainer c = LoadSave.Deserialize <tp_Containers.SettingsContainer>(file);
                component.Opacity   = c.opacity;
                component.Strength  = c.strength;
                component.BrushSize = c.size;

                component.Heights.Clear();
                for (int i = 0; i < c.heights.Length; i++)
                {
                    component.Heights.Add(c.heights[i]);
                }
                component.Ramp.Set(c.ramp);


                // Print how long it took to load the splatmaps
                Debug.Log("Loading settings finished!");
            }
        }
Ejemplo n.º 2
0
        private void LoadSplatMap()
        {
            // Get file path
            string path = EditorUtility.OpenFilePanel("Load Terrain Splatmaps", "", "xml");

            if (path.Length > 0)
            {
                // Get current time for determining how long it takes to load the splatmaps
                DateTime dt = DateTime.Now;

                // Desirialize data
                StreamReader reader = new StreamReader(path);
                string       file   = reader.ReadToEnd();
                reader.Close();

                // Convert deserialized data to splatmaps
                tp_Containers.SplatmapContainer tc = LoadSave.Deserialize <tp_Containers.SplatmapContainer>(file);
                float[,,] splat = tc.GetSplatmap();

                // Set splatmap
                component.TerrainData.SetAlphamaps(0, 0, splat);

                // Print how long it took to load the splatmaps
                Debug.Log("Loading splatmap finished! time: [" + (DateTime.Now - dt).ToString() + "]");
            }
        }
Ejemplo n.º 3
0
        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!");
            }
        }
Ejemplo n.º 4
0
        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() + "]");
            }
        }