Esempio 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!");
            }
        }
Esempio n. 2
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!");
            }
        }
Esempio 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!");
            }
        }