コード例 #1
0
        public bool SaveDecalMesh(DMesh dm)
        {
            string path_to_file = Path.ChangeExtension(Path.Combine(editor.m_filepath_decals, dm.name), ".dmesh");

            try {
                JObject root = new JObject();
                dm.Serialize(root);

                string new_file_data = root.ToString(Formatting.Indented);

                if (File.Exists(path_to_file))
                {
                    // if the file already exists, and it is the same, do not write it
                    // out - preserving file timestamps
                    try {
                        string old_file_data = File.ReadAllText(path_to_file);
                        if (old_file_data == new_file_data)
                        {
                            // ignore - nothing changed
                            return(true);
                        }
                    }
                    catch {
                    }
                }

                File.WriteAllText(path_to_file, new_file_data);

                return(true);
            }
            catch (Exception ex) {
                Utility.DebugLog("Failed to save decal mesh: " + ex.Message);
                return(false);
            }
        }
        public bool SaveDecalMesh(DMesh dm, string path_to_file, bool silent = false)
        {
            try {
                JObject root = new JObject();
                dm.DeconvertPolysToTris();

                dm.Serialize(root);

                string new_file_data = root.ToString(Formatting.Indented);

                File.WriteAllText(path_to_file, new_file_data);

                if (!silent)
                {
                    this.m_filepath_current_decal = path_to_file;
                    this.Text = "Overload DMesh Editor - " + path_to_file;

                    AddOutputText(string.Format("Saved decal: {0}", path_to_file));

                    AddRecentFile(path_to_file);
                    dm.dirty = false;
                }

                return(true);
            }
            catch (Exception ex) {
                Utility.DebugLog("Failed to save decal mesh: " + ex.Message);
                return(false);
            }
        }