AddLanguage() public méthode

public AddLanguage ( string language ) : void
language string
Résultat void
Exemple #1
0
        private void DrawLanguages(LeanLocalization localization)
        {
            var labelA = Reserve();
            var valueA = Reserve(ref labelA, 35.0f);

            EditorGUI.LabelField(labelA, "Languages", EditorStyles.boldLabel);

            // Add a new language?
            if (GUI.Button(valueA, "Add") == true)
            {
                MarkAsModified();

                var menu = new GenericMenu();

                for (var i = 0; i < newLanguages.Length; i++)
                {
                    var newLanguage = newLanguages[i];

                    menu.AddItem(new GUIContent(newLanguage), false, () => localization.AddLanguage(newLanguage));
                }

                menu.DropDown(valueA);
            }

            existingLanguages.Clear();

            // Draw all added languages
            for (var i = 0; i < localization.Languages.Count; i++)
            {
                var labelB   = Reserve();
                var valueB   = Reserve(ref labelB, 20.0f);
                var language = localization.Languages[i];

                // Edit language name or remove
                if (languageIndex == i)
                {
                    BeginModifications();
                    {
                        localization.Languages[i] = EditorGUI.TextField(labelB, language);
                    }
                    EndModifications();

                    if (GUI.Button(valueB, "X") == true)
                    {
                        MarkAsModified();

                        localization.Languages.RemoveAt(i); languageIndex = -1;
                    }
                }

                // Expand language?
                if (EditorGUI.Foldout(labelB, languageIndex == i, languageIndex == i ? "" : language) == true)
                {
                    if (languageIndex != i)
                    {
                        languageIndex = i;
                        reverseIndex  = -1;
                    }

                    EditorGUI.indentLevel += 1;
                    {
                        DrawReverse(localization, language);
                    }
                    EditorGUI.indentLevel -= 1;

                    EditorGUILayout.Separator();
                }
                else if (languageIndex == i)
                {
                    languageIndex = -1;
                    reverseIndex  = -1;
                }

                // Already added?
                if (existingLanguages.Contains(language) == true)
                {
                    EditorGUILayout.HelpBox("This language already exists in the list!", MessageType.Warning);
                }
                else
                {
                    existingLanguages.Add(language);
                }
            }
        }
        private void DrawLanguages(LeanLocalization localization)
        {
            var labelA = Reserve();
            var valueA = Reserve(ref labelA, 35.0f);

            EditorGUI.LabelField(labelA, "Languages", EditorStyles.boldLabel);

            // Add a new language?
            if (GUI.Button(valueA, "Add") == true)
            {
                MarkAsModified();

                var menu = new GenericMenu();

                for (var i = 0; i < newLanguages.Length; i++)
                {
                    var newLanguage = newLanguages[i];

                    menu.AddItem(new GUIContent(newLanguage), false, () => localization.AddLanguage(newLanguage));
                }

                menu.DropDown(valueA);
            }

            existingLanguages.Clear();

            // Draw all added languages
            for (var i = 0; i < localization.Languages.Count; i++)
            {
                var labelB   = Reserve();
                var valueB   = Reserve(ref labelB, 20.0f);
                var language = localization.Languages[i];

                // Edit language name or remove
                if (languageIndex == i)
                {
                    BeginModifications();
                    {
                        localization.Languages[i] = EditorGUI.TextField(labelB, language);
                    }
                    EndModifications();

                    if (GUI.Button(valueB, "X") == true)
                    {
                        MarkAsModified();

                        localization.Languages.RemoveAt(i); languageIndex = -1;
                    }
                }

                // Expand language?
                if (EditorGUI.Foldout(labelB, languageIndex == i, languageIndex == i ? "" : language) == true)
                {
                    if (languageIndex != i)
                    {
                        languageIndex = i;
                        reverseIndex  = -1;
                    }

                    EditorGUI.indentLevel += 1;
                    {
                        DrawReverse(localization, language);
                    }
                    EditorGUI.indentLevel -= 1;

                    EditorGUILayout.Separator();
                }
                else if (languageIndex == i)
                {
                    languageIndex = -1;
                    reverseIndex  = -1;
                }

                // Already added?
                if (existingLanguages.Contains(language) == true)
                {
                    EditorGUILayout.HelpBox("This language already exists in the list!", MessageType.Warning);
                }
                else
                {
                    existingLanguages.Add(language);
                }
            }
        }