Browse Source

Improved LocalizationEditor.ExportLocalizationFile

Save file dialog defaults to the Assets folder.
Automatically sets the localisation file property to reference the
exported file.
master
chrisgregan 10 years ago
parent
commit
057203af42
  1. 14
      Assets/Fungus/Narrative/Editor/LocalizationEditor.cs

14
Assets/Fungus/Narrative/Editor/LocalizationEditor.cs

@ -57,8 +57,10 @@ namespace Fungus
public virtual void ExportLocalizationFile(Localization localization) public virtual void ExportLocalizationFile(Localization localization)
{ {
string path = EditorUtility.SaveFilePanel("Export Localization File", "Assets/", string path = EditorUtility.SaveFilePanelInProject("Export Localization File",
"localization.csv", ""); "localization.csv",
"csv",
"Please enter a filename to save the localization file to");
if (path.Length == 0) if (path.Length == 0)
{ {
return; return;
@ -66,7 +68,13 @@ namespace Fungus
string csvData = localization.GetCSVData(); string csvData = localization.GetCSVData();
File.WriteAllText(path, csvData); 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); ShowNotification(localization);
} }

Loading…
Cancel
Save