void SetCurrentValues() { values = new string[Enum.GetNames(typeof(Language)).Length]; for (int i = 0; i < values.Length; i++) { values[i] = LocalisationManager.GetLocalisedValue(key, (Language)i); } }
void GetSearchResults() { EditorGUILayout.BeginVertical(); scroll = EditorGUILayout.BeginScrollView(scroll); foreach (KeyValuePair <string, string> element in anyDictionary) { if (element.Key.ToLower().Contains(value.ToLower())) { EditorGUILayout.BeginHorizontal("box"); if (GUILayout.Button(element.Key)) { sp.stringValue = element.Key; sp.serializedObject.ApplyModifiedProperties(); instance.Close(); } GUIContent editContent = new GUIContent("edit"); if (GUILayout.Button(editContent, GUILayout.MaxWidth(40), GUILayout.MaxHeight(20))) { TextLocaliserEditWindow.Open(element.Key); } GUIContent deleteContent = new GUIContent("delete"); if (GUILayout.Button(deleteContent, DeleteGUIStyle(), GUILayout.MaxWidth(55), GUILayout.MaxHeight(20))) { if (EditorUtility.DisplayDialog("Removing key", "Are you sure you want to remove key " + element.Key + "?", "Remove", "Cancel")) { LocalisationManager.Remove(element.Key); AssetDatabase.Refresh(); LocalisationManager.Init(); anyDictionary = LocalisationManager.GetAnyDictionaryForKeys(); } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public void OnGUI() { EditorGUILayout.LabelField(key, KeyGUIStyle()); scroll = EditorGUILayout.BeginScrollView(scroll); string[] languages = Enum.GetNames(typeof(Language)); for (int i = 0; i < languages.Length; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(languages[i] + ": ", GUILayout.MaxWidth(70)); EditorStyles.textArea.wordWrap = true; values[i] = EditorGUILayout.TextArea(values[i], EditorStyles.textArea, GUILayout.Height(50), GUILayout.Width(400)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Update")) { for (int i = 0; i < values.Length; i++) { if (values[i] == null) { values[i] = string.Empty; } values[i] = values[i].Replace("\n", "\\n"); } LocalisationManager.Replace(key, values); window.Close(); window = null; } minSize = new Vector2(480, 250); maxSize = minSize; }
private GUIStyle GetGUIStyle(string key) { GUIStyle style = new GUIStyle(EditorStyles.textField); Dictionary <string, string> anyDictionary = LocalisationManager.GetAnyDictionaryForKeys(); foreach (KeyValuePair <string, string> element in anyDictionary) { if (string.Equals(element.Key, key)) { return(style); // return default } } style = new GUIStyle(EditorStyles.textField); style.normal.textColor = Color.gray; style.active.textColor = Color.gray; style.focused.textColor = Color.gray; style.hover.textColor = Color.gray; return(style); }
private void OnEnable() { anyDictionary = LocalisationManager.GetAnyDictionaryForKeys(); }