Example #1
0
        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);
        }
Example #2
0
        static void DrawEditButton(Rect position, string key)
        {
            Texture searchIcon = (Texture)Resources.Load("options");

            GUIContent _content = new GUIContent(searchIcon);

            if (CheckIsValid(key))
            {
                if (GUI.Button(position, _content))
                {
                    if (CheckIsValid(key))
                    {
                        TextLocaliserGUIEditorEditWindow.Open(key);
                    }
                }
            }
        }
Example #3
0
        static void DrawEditButton(string key)
        {
            Texture searchIcon = (Texture)Resources.Load("options");

            GUIContent _content = new GUIContent(searchIcon);

            if (CheckIsValid(key))
            {
                if (GUILayout.Button(_content, GUILayout.MaxHeight(17), GUILayout.MaxWidth(17)))
                {
                    if (CheckIsValid(key))
                    {
                        TextLocaliserGUIEditorEditWindow.Open(key);
                    }
                }
            }
        }
Example #4
0
        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();
        }