private void GetSearchResults() //Draw the search results
    {
        if (value == null)
        {
            value = "";
        }                                  //If the value is null, just set it to empty so that no errors occur

        EditorGUILayout.BeginVertical();
        scroll = EditorGUILayout.BeginScrollView(scroll);

        //For each key, draw its corresponding value in a list format
        foreach (KeyValuePair <string, string> element in dictionary)
        {
            if (element.Key.ToLower().Contains(value.ToLower()) || element.Value.ToLower().Contains(value.ToLower()))
            {
                //Delete Entry Button
                EditorGUILayout.BeginHorizontal("box");
                GUIContent deleteButton = EditorGUIUtility.IconContent("d_LookDevClose@2x"); //This is an X icon...

                if (GUILayout.Button(deleteButton, GUILayout.MaxWidth(20), GUILayout.MaxHeight(20)))
                {
                    if (EditorUtility.DisplayDialog("Remove Key '" + element.Key + "'?", "This will remove the element from localization, are you sure?", "Yes I'm Sure", "Cancel"))
                    {
                        LocalizationSystem.Remove(element.Key);
                        AssetDatabase.Refresh();
                        LocalizationSystem.Init();
                        dictionary = LocalizationSystem.GetDictionaryForEditor();
                    }
                }

                //Clipboard Copy Button
                GUIContent copyContent = EditorGUIUtility.IconContent("Clipboard"); //This is a clipboard icon...
                if (GUILayout.Button(copyContent, GUILayout.MaxWidth(20), GUILayout.MaxHeight(20)))
                {
                    //Copy to clipboard
                    TextEditor te = new TextEditor();
                    te.text = element.Key;
                    te.SelectAll();
                    te.Copy();
                }

                //Draw the values
                EditorGUILayout.TextField(element.Key);
                EditorGUILayout.LabelField(element.Value);
                EditorGUILayout.EndHorizontal();
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
Beispiel #2
0
    private void GetSearchResults()
    {
        if (value == null)
        {
            return;
        }

        EditorGUILayout.BeginVertical();
        scroll = EditorGUILayout.BeginScrollView(scroll);

        foreach (KeyValuePair <string, string> element in dictionary)
        {
            if (element.Key.ToLower().Contains(value.ToLower()) || element.Value.ToLower().Contains(value.ToLower()))
            {
                EditorGUILayout.BeginHorizontal("box");
                Texture closeIcon = (Texture)Resources.Load("trash");

                GUIContent content = new GUIContent(closeIcon, "Delete");

                if (GUILayout.Button(content, GUILayout.MaxWidth(20)))
                {
                    string warningMsg      = "This will remove the element from the localization, are you sure?";
                    string confirmationMsg = "Do it";

                    if (EditorUtility.DisplayDialog("Remove Key " + element.Key + "?", warningMsg, confirmationMsg))
                    {
                        LocalizationSystem.Remove(element.Key);
                        AssetDatabase.Refresh();
                        LocalizationSystem.Init();
                        dictionary = LocalizationSystem.GetDictionaryForEditor();
                    }
                }

                EditorGUILayout.TextField(element.Key);
                EditorGUILayout.LabelField(element.Value);
                EditorGUILayout.EndHorizontal();
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
    private void GetSearchResults()
    {
        if (value == null)
        {
            value = "";                  /*return;*/
        }

        EditorGUILayout.BeginVertical();
        scroll = EditorGUILayout.BeginScrollView(scroll);
        foreach (KeyValuePair <string, string> element in dictionary)
        {
            if (element.Key.ToLower().Contains(value.ToLower()) || element.Value.ToLower().Contains(value.ToLower()))
            {
                var        r         = EditorGUILayout.BeginHorizontal("Box");
                Texture    closeIcon = (Texture)Resources.Load("Icons\\close");
                GUIContent content   = new GUIContent(closeIcon);
                if (GUILayout.Button(content, GUILayout.MaxWidth(20), GUILayout.MaxHeight(20)))
                {
                    if (EditorUtility.DisplayDialog($"Remove key {element.Key} ?", "This will remove the element from localization are you sure?", "Do it"))
                    {
                        LocalizationSystem.Remove(element.Key);
                        AssetDatabase.Refresh();
                        LocalizationSystem.Init();
                        dictionary = LocalizationSystem.GetDictionaryForEditor();
                    }
                }
                EditorGUILayout.TextField(element.Key);
                EditorGUILayout.LabelField(element.Value);
                EditorGUILayout.EndHorizontal();
                if (element.Key.ToLower() == value.ToLower() || element.Value.ToLower() == value.ToLower())
                {
                    Color backgroundColor = new Color(1f, 0.0f, 0.0f, 0.3f);
                    Rect  rx = new Rect(r.x, r.y, EditorGUIUtility.currentViewWidth, r.height);
                    EditorGUI.DrawRect(rx, backgroundColor);
                }
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
Beispiel #4
0
 private void OnEnable()
 {
     dictionary = LocalizationSystem.GetDictionaryForEditor();
 }
    private void GetSearchResults()
    {
        EditorGUILayout.BeginVertical();
        scroll = EditorGUILayout.BeginScrollView(scroll);
        foreach (KeyValuePair <string, string> element in dictionary)
        {
            if (value == null)
            {
                EditorGUILayout.BeginHorizontal("box");
                Texture checkIcon = Resources.Load <Texture>("Icons/check");

                GUIContent contentCheck = new GUIContent(checkIcon);

                if (GUILayout.Button(contentCheck, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
                {
                    Close();
                    AssetDatabase.Refresh();
                }

                Texture closeIcon = Resources.Load <Texture>("Icons/close");

                GUIContent contentClose = new GUIContent(closeIcon);

                if (GUILayout.Button(contentClose, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
                {
                    if (EditorUtility.DisplayDialog("Remove key " + element.Key + "?",
                                                    "This will remove the element from localizaton, are you sure?", "Do it"))
                    {
                        LocalizationSystem.Remove(element.Key);
                        AssetDatabase.Refresh();
                        LocalizationSystem.Init();
                        dictionary = LocalizationSystem.GetDictionaryForEditor();
                    }
                }

                EditorGUILayout.TextField(element.Key);
                EditorGUILayout.LabelField(element.Value);
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                if (element.Key.ToLower().Contains(value.ToLower()) || element.Value.ToLower().Contains(value.ToLower()))
                {
                    EditorGUILayout.BeginHorizontal("box");
                    Texture checkIcon = Resources.Load <Texture>("Icons/check");

                    GUIContent contentCheck = new GUIContent(checkIcon);

                    if (GUILayout.Button(contentCheck, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
                    {
                        Close();
                        AssetDatabase.Refresh();
                    }

                    Texture closeIcon = Resources.Load <Texture>("Icons/close");

                    GUIContent contentClose = new GUIContent(closeIcon);

                    if (GUILayout.Button(contentClose, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
                    {
                        if (EditorUtility.DisplayDialog("Remove key " + element.Key + "?",
                                                        "This will remove the element from localizaton, are you sure?", "Do it"))
                        {
                            LocalizationSystem.Remove(element.Key);
                            AssetDatabase.Refresh();
                            LocalizationSystem.Init();
                            dictionary = LocalizationSystem.GetDictionaryForEditor();
                        }
                    }

                    EditorGUILayout.TextField(element.Key);
                    EditorGUILayout.LabelField(element.Value);
                    EditorGUILayout.EndHorizontal();
                }
            }
        }

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
 private void OnEnable() //Get the dictionary for the editor (DEFAULT: English)
 {
     dictionary = LocalizationSystem.GetDictionaryForEditor();
 }