public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); position.width -= 48; position.height = 18; Rect valueRect = new Rect(position); valueRect.x += 15; valueRect.width -= 15; Rect foldButtonRect = new Rect(position); foldButtonRect.width = 15; EditorGUI.LabelField(position, "Key", EditorStyles.wordWrappedLabel); position.x += 30; position.width -= 80; SerializedProperty key = property.FindPropertyRelative("key"); key.stringValue = EditorGUI.TextField(position, key.stringValue, GetGUIStyle(key.stringValue)); position.x += position.width + 2; position.width = 40; position.height = 18; GUIContent editContent = new GUIContent("edit"); GUI.enabled = key.stringValue != string.Empty; if (GUI.Button(position, editContent)) { TextLocaliserEditWindow.Open(key.stringValue); } GUI.enabled = true; position.x += position.width + 2; position.width = 54; GUIContent searchContent = new GUIContent("search"); if (GUI.Button(position, searchContent)) { TextLocaliserSearchWindow.Open(key); } EditorGUI.EndProperty(); }
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(); }