From 057203af42c58a5ba12673e7c92a0c93db74ff38 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 30 Apr 2015 10:34:12 +0100 Subject: [PATCH] Improved LocalizationEditor.ExportLocalizationFile Save file dialog defaults to the Assets folder. Automatically sets the localisation file property to reference the exported file. --- .../Fungus/Narrative/Editor/LocalizationEditor.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs b/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs index 87af5c94..3239c89f 100644 --- a/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs +++ b/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs @@ -57,8 +57,10 @@ namespace Fungus public virtual void ExportLocalizationFile(Localization localization) { - string path = EditorUtility.SaveFilePanel("Export Localization File", "Assets/", - "localization.csv", ""); + string path = EditorUtility.SaveFilePanelInProject("Export Localization File", + "localization.csv", + "csv", + "Please enter a filename to save the localization file to"); if (path.Length == 0) { return; @@ -66,7 +68,13 @@ namespace Fungus string csvData = localization.GetCSVData(); File.WriteAllText(path, csvData); - AssetDatabase.Refresh(); + AssetDatabase.ImportAsset(path); + + TextAsset textAsset = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)) as TextAsset; + if (textAsset != null) + { + localization.localizationFile = textAsset; + } ShowNotification(localization); }