private static void DownloadGoogleSheet(string docsId, string sheetId, LocalizationAssetFormat format, TextAsset textAsset) { EditorUtility.DisplayCancelableProgressBar("Download", "Downloading...", 0); var url = string.Format("https://docs.google.com/spreadsheets/d/{0}/export?format={2}&gid={1}", docsId, sheetId, Enum.GetName(typeof(LocalizationAssetFormat), format).ToLower()); Debug.Log(url); #if UNITY_2017_1_OR_NEWER var www = UnityWebRequest.Get(url); www.SendWebRequest(); #elif UNITY_5_5_OR_NEWER var www = UnityWebRequest.Get(url); www.Send(); #else var www = new WWW(url); #endif while (!www.isDone) { #if UNITY_5_5_OR_NEWER var progress = www.downloadProgress; #else var progress = www.progress; #endif if (EditorUtility.DisplayCancelableProgressBar("Download", "Downloading...", progress)) { return; } } EditorUtility.ClearProgressBar(); var path = textAsset != null?AssetDatabase.GetAssetPath(textAsset) : null; if (string.IsNullOrEmpty(path)) { path = EditorUtility.SaveFilePanelInProject("Save Localization", "", "txt", "Please enter a file name to save the csv to", path); } if (string.IsNullOrEmpty(path)) { return; } #if UNITY_5_5_OR_NEWER var text = www.downloadHandler.text; #else var text = www.text; #endif if (text.StartsWith("<!")) { Debug.LogError("Google sheet could not be downloaded\n" + text); return; } File.WriteAllText(path, text); Debug.Log("Importing " + path); AssetDatabase.ImportAsset(path); LocalizationImporter.Refresh(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int index = 0; index < importedAssets.Length; index++) { var str = importedAssets[index]; if (str.EndsWith(".csv") && str.Contains("Localization")) { LocalizationImporter.Refresh(); } } }
public override void OnInspectorGUI() { if (refresh) { LocalizationImporter.Refresh(); refresh = false; } EditorGUI.BeginChangeCheck(); serializedObject.Update(); EditorGUILayout.LabelField("Polyglot Localization Settings", (GUIStyle)"IN TitleText"); var polyglotPath = GetPrefsString(PathPrefs); if (string.IsNullOrEmpty(polyglotPath)) { polyglotPath = DefaultPolyglotPath; } var changed = false; if (UpdateTextAsset("polyglotDocument", masterSheet)) { changed = true; masterSheet = null; } DisplayDocsAndSheetId("Official Polyglot Master", true, false, masterSheet, serializedObject.FindProperty("polyglotDocument"), OfficialSheet, OfficialGId, polyglotPath, DownloadMasterSheet); EditorGUILayout.Space(); if (UpdateTextAsset("customDocument", customSheet)) { changed = true; customSheet = null; } DisplayDocsAndSheetId("Custom Sheet", false, !ValidateDownloadCustomSheet(), customSheet, serializedObject.FindProperty("customDocument"), GetPrefsString(CustomDocsIdPrefs), GetPrefsString(CustomSheetIdPrefs), GetPrefsString(CustomPathPrefs), DownloadCustomSheet); EditorGUILayout.Space(); EditorGUILayout.LabelField("Localization Settings", (GUIStyle)"IN TitleText"); var iterator = serializedObject.GetIterator(); for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { if (iterator.propertyPath.Contains("Document")) { continue; } #if !ARABSUPPORT_ENABLED if (iterator.propertyPath == "Localize") { using (new EditorGUI.DisabledGroupScope(true)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Arabic Support", (GUIStyle)"BoldLabel"); EditorGUILayout.HelpBox("Enable Arabic Support with ARABSUPPORT_ENABLED post processor flag", MessageType.Info); EditorGUILayout.Toggle(new GUIContent("Show Tashkeel", "Enable Arabic Support with ARABSUPPORT_ENABLED post processor flag"), true); EditorGUILayout.Toggle(new GUIContent("Use Hindu Numbers", "Enable Arabic Support with ARABSUPPORT_ENABLED post processor flag"), false); } } #endif using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath)) EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); } #if !ARABSUPPORT_ENABLED #endif serializedObject.ApplyModifiedProperties(); if (changed || EditorGUI.EndChangeCheck()) { refresh = true; } }