public static void Open(string key) { TextLocaliserGUIEditorEditWindow window = new TextLocaliserGUIEditorEditWindow(); window.titleContent = new GUIContent("Edit Value"); window.ShowUtility(); window.key = key; window.localisationValue = TextLocalisation.GetLocalisedValue(key); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (property.isExpanded) { var value = TextLocalisation.GetLocalisedValue(property.FindPropertyRelative("key").stringValue); return(height); } return(21); }
void Set() { _textBox = GetComponent <TextMeshProUGUI>(); string val = TextLocalisation.GetLocalisedValue(key); _textBox.text = TextLocalisation.GetLocalisedValue(key); if (gameObject.GetComponent <UITextAnimator>()) { gameObject.GetComponent <UITextAnimator>().Set(val); } }
public void OnGUI() { EditorGUILayout.BeginHorizontal("Box"); if (GUILayout.Button("Refresh", GUILayout.MaxWidth(60))) { AssetDatabase.Refresh(); TextLocalisation.Refresh(); dic = TextLocalisation.GetDictionaryForEditor(); } EditorGUILayout.LabelField("Search: ", EditorStyles.boldLabel); value = EditorGUILayout.TextField(value); EditorGUILayout.EndHorizontal(); GetSearchResults(); }
public static string TextField(string label, string key) { EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); key = EditorGUILayout.TextField(label, key); DrawSearchButton(); DrawAddButton(key); DrawEditButton(key); EditorGUILayout.EndHorizontal(); if (CheckIsValid(key)) { GUI.skin.textField.wordWrap = true; EditorGUILayout.LabelField(" ", TextLocalisation.GetLocalisedValue(key), EditorStyles.wordWrappedLabel, GUILayout.Height(50)); GUI.skin.textField.wordWrap = false; } EditorGUILayout.EndVertical(); return(key); }
public void OnGUI() { EditorGUILayout.LabelField("Key: ", key); localisationValue = TextLocaliserGUIEditorAlertWindow.DrawToolbar(localisationValue); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Value:", GUILayout.MaxWidth(50)); EditorStyles.textArea.wordWrap = true; localisationValue = EditorGUILayout.TextArea(localisationValue, EditorStyles.textArea, GUILayout.Height(180), GUILayout.Width(400)); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Add")) { TextLocalisation.ReplaceValue(localisationValue, key); TextLocalisation.Refresh(); Close(); } minSize = new Vector2(460, 280); maxSize = minSize; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Keyboard), label); position.height = 18; Rect foldoutRect = new Rect(position); foldoutRect.width = 25; property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, "", true); position.x += 35; position.width -= 75; TextLocaliserEditorGUI.TextPropertyField(position, property); if (property.isExpanded) { var value = TextLocalisation.GetLocalisedValue(property.FindPropertyRelative("key").stringValue); GUIStyle style = new GUIStyle(EditorStyles.wordWrappedLabel); var newHeight = style.CalcHeight(new GUIContent(value), position.width) + 22; if (newHeight > height) { height = newHeight; } position.height = height; position.y += 21; EditorGUI.LabelField(position, value, EditorStyles.wordWrappedLabel); } EditorGUI.EndProperty(); }
static bool CheckIsValid(string key) { if (key == null) { return(false); } if (key == string.Empty) { return(false); } if (key == "") { return(false); } if (TextLocalisation.GetLocalisedValue(key) == null) { return(false); } else { return(true); } }
public static string GetValue(string key) { return(TextLocalisation.GetLocalisedValue(key)); }
void GetSearchResults() { if (value == null) { return; } Color c = GUI.color; EditorGUILayout.BeginVertical(); scroll = EditorGUILayout.BeginScrollView(scroll); foreach (KeyValuePair <string, string> element in dic) { if (element.Key.ToLower().Contains(value.ToLower()) || element.Value.ToLower().Contains(value.ToLower())) { EditorGUILayout.BeginHorizontal("box"); //Draw a delete button Texture closeIcon = (Texture)Resources.Load("close"); Texture saveIcon = (Texture)Resources.Load("edit"); GUIContent _content = new GUIContent(closeIcon); GUI.color = Color.red; if (GUILayout.Button(_content, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20))) { if (EditorUtility.DisplayDialog("Remove Key " + element.Key + "?", "This will remove the element from localisation. Are you sure?", "Do It!")) { TextLocalisation.RemoveKey(element.Key); AssetDatabase.Refresh(); TextLocalisation.Refresh(); dic = TextLocalisation.GetDictionaryForEditor(); } } GUI.color = c; _content = new GUIContent(saveIcon); if (GUILayout.Button(_content, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20))) { TextLocaliserGUIEditorEditWindow.Open(element.Key); } EditorGUILayout.TextField(element.Key); EditorGUILayout.LabelField(element.Value); if (this.isDropdown) { GUI.color = Color.yellow; Texture addIcon = (Texture)Resources.Load("store"); GUIContent _add = new GUIContent(addIcon); if (GUILayout.Button(_add, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20))) { try { GameObject obj = Selection.activeGameObject; if (obj.GetComponent <UITextLocaliser>() != null) { obj.GetComponent <UITextLocaliser>().key = element.Key; } else { if (property != null) { if (property.FindPropertyRelative("key") != null) { property.FindPropertyRelative("key").stringValue = element.Key; } else if (property.FindPropertyRelative("text") != null) { property.FindPropertyRelative("text").stringValue = element.Key; } property.serializedObject.ApplyModifiedProperties(); } } } catch { if (property != null) { if (property.FindPropertyRelative("key") != null) { property.FindPropertyRelative("key").stringValue = element.Key; } else if (property.FindPropertyRelative("text") != null) { property.FindPropertyRelative("text").stringValue = element.Key; } property.serializedObject.ApplyModifiedProperties(); } } Close(); } GUI.color = c; } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
private void OnEnable() { dic = TextLocalisation.GetDictionaryForEditor(); }