private static void DownloadCustomSheet() { var doc = Localization.Instance.CustomDocument; DownloadGoogleSheet(doc); customSheet = new LocalizationAsset { TextAsset = doc.TextAsset, Format = doc.Format }; }
private static void DownloadMasterSheet() { var doc = Localization.Instance.PolyglotDocument; DownloadGoogleSheet(doc); masterSheet = new LocalizationAsset { TextAsset = doc.TextAsset, Format = doc.Format }; }
private bool UpdateTextAsset(string documentProperty, LocalizationAsset localizationAsset) { if (localizationAsset == null) { return(false); } var document = serializedObject.FindProperty(documentProperty); var textAssetProps = document.FindPropertyRelative("textAsset"); if (textAssetProps.objectReferenceValue == null) { textAssetProps.objectReferenceValue = localizationAsset.TextAsset; } var filesList = serializedObject.FindProperty("inputFiles"); var found = false; for (int i = 0; i < filesList.arraySize; i++) { var inputFile = filesList.GetArrayElementAtIndex(i); var textAssetProp = inputFile.FindPropertyRelative("textAsset"); var formatProp = inputFile.FindPropertyRelative("format"); if (textAssetProp.objectReferenceValue == localizationAsset.TextAsset && formatProp.enumValueIndex == (int)localizationAsset.Format) { found = true; break; } } if (!found) { var lastIndex = filesList.arraySize; filesList.InsertArrayElementAtIndex(lastIndex); var inputFile = filesList.GetArrayElementAtIndex(lastIndex); var textAssetProp = inputFile.FindPropertyRelative("textAsset"); textAssetProp.objectReferenceValue = localizationAsset.TextAsset; var formatProp = inputFile.FindPropertyRelative("format"); formatProp.enumValueIndex = (int)localizationAsset.Format; return(true); } return(false); }
private static void DisplayDocsAndSheetId(string title, bool disableId, bool disableOpen, LocalizationAsset sheet, SerializedProperty document, string defaultDocs, string defaultSheet, string defaultTextAssetPath, Action download) { EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField(title, (GUIStyle)"IN TitleText"); EditorGUI.BeginDisabledGroup(disableId); var docsIdProp = document.FindPropertyRelative("docsId"); if (string.IsNullOrEmpty(docsIdProp.stringValue)) { docsIdProp.stringValue = defaultDocs; } EditorGUILayout.PropertyField(docsIdProp); var sheetIdProps = document.FindPropertyRelative("sheetId"); if (string.IsNullOrEmpty(sheetIdProps.stringValue)) { sheetIdProps.stringValue = defaultSheet; } EditorGUILayout.PropertyField(sheetIdProps); var textAssetProps = document.FindPropertyRelative("textAsset"); if (textAssetProps.objectReferenceValue == null && !string.IsNullOrEmpty(defaultTextAssetPath)) { textAssetProps.objectReferenceValue = AssetDatabase.LoadAssetAtPath <TextAsset>(defaultTextAssetPath); } EditorGUILayout.PropertyField(textAssetProps); EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(disableOpen); var downloadOnstartProps = document.FindPropertyRelative("downloadOnStart"); EditorGUILayout.PropertyField(downloadOnstartProps); var formatProps = document.FindPropertyRelative("format"); EditorGUILayout.PropertyField(formatProps); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(string.Empty); if (GUILayout.Button("Open")) { var url = string.Format("https://docs.google.com/spreadsheets/d/{0}/edit#gid={1}", docsIdProp.stringValue, sheetIdProps.stringValue); Application.OpenURL(url); } if (GUILayout.Button("Download")) { download(); } EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); }
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; } }