private void Export()
        {
            try
            {
                // PersonalityTraits.csv:
                EditorUtility.DisplayProgressBar("Exporting Faction Database To CSV", "Exporting personality trait definitions...", 0);
                var csv = new List <List <string> >();
                csv.Add(new List <string>(new string[] { "Name", "Description" }));
                for (int i = 0; i < db.personalityTraitDefinitions.Length; i++)
                {
                    var def = db.personalityTraitDefinitions[i];
                    csv.Add(new List <string>(new string[] { def.name, def.description }));
                }
                CSVUtility.WriteCSVFile(csv, prefs.folder + "/PersonalityTraits.csv", prefs.encoding);

                // RelationshipTraits.csv:
                EditorUtility.DisplayProgressBar("Exporting Faction Database To CSV", "Exporting relationship trait definitions...", 40);
                csv = new List <List <string> >();
                csv.Add(new List <string>(new string[] { "Name", "Description" }));
                for (int i = 0; i < db.relationshipTraitDefinitions.Length; i++)
                {
                    var def = db.relationshipTraitDefinitions[i];
                    csv.Add(new List <string>(new string[] { def.name, def.description }));
                }
                CSVUtility.WriteCSVFile(csv, prefs.folder + "/RelationshipTraits.csv", prefs.encoding);

                // Factions.csv:
                EditorUtility.DisplayProgressBar("Exporting Faction Database To CSV", "Exporting factions...", 60);
                csv = new List <List <string> >();
                var row = new List <string>(new string[] { "ID", "Name", "Description", "Preset", "Color", "%Judge Parents" });
                for (int i = 0; i < db.personalityTraitDefinitions.Length; i++)
                {
                    row.Add(db.personalityTraitDefinitions[i].name);
                }
                row.Add("Parents");
                csv.Add(row);
                for (int i = 0; i < db.presets.Length; i++)
                {
                    var preset = db.presets[i];
                    row = new List <string>(new string[] { "-1", preset.name, preset.description, "1", "0", "0" });
                    for (int j = 0; j < db.personalityTraitDefinitions.Length; j++)
                    {
                        row.Add(preset.traits[j].ToString());
                    }
                    csv.Add(row);
                }
                for (int i = 0; i < db.factions.Length; i++)
                {
                    var faction = db.factions[i];
                    row = new List <string>(new string[] { faction.id.ToString(), faction.name, faction.description, "0", faction.color.ToString(), faction.percentJudgeParents.ToString() });
                    for (int j = 0; j < db.personalityTraitDefinitions.Length; j++)
                    {
                        row.Add(faction.traits[j].ToString());
                    }
                    for (int j = 0; j < faction.parents.Length; j++)
                    {
                        row.Add(db.factions[faction.parents[j]].name);
                    }
                    csv.Add(row);
                }
                CSVUtility.WriteCSVFile(csv, prefs.folder + "/Factions.csv", prefs.encoding);

                // Relationships.csv:
                EditorUtility.DisplayProgressBar("Exporting Faction Database To CSV", "Exporting relationships...", 80);
                for (int i = 0; i < db.relationshipTraitDefinitions.Length; i++)
                {
                    csv = new List <List <string> >();
                    row = new List <string>(new string[] { db.relationshipTraitDefinitions[i].name });
                    for (int j = 0; j < db.factions.Length; j++)
                    {
                        row.Add(db.factions[j].name);
                    }
                    csv.Add(row);
                    for (int j = 0; j < db.factions.Length; j++)
                    {
                        var judge = db.factions[j];
                        row = new List <string>(new string[] { judge.name });
                        for (int k = 0; k < db.factions.Length; k++)
                        {
                            var          subject = db.factions[k];
                            Relationship relationship;
                            if (db.FindPersonalRelationship(judge.id, subject.id, out relationship))
                            {
                                row.Add(relationship.traits[i].ToString());
                            }
                            else
                            {
                                row.Add("none");
                            }
                        }
                        csv.Add(row);
                    }
                    CSVUtility.WriteCSVFile(csv, prefs.folder + "/Relationships_" + GetValidFilespec(db.relationshipTraitDefinitions[i].name) + ".csv", prefs.encoding);
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
            Debug.Log("Exported " + db.name + " to CSV files in " + prefs.folder + ".", db);
        }