示例#1
0
        public IEnumerator ListViewUpdatesWhenLocaleIsRemoved()
        {
            WrapperWindow window = GetWindow((wnd) =>
            {
                // Perform an update
                var height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none);
                m_PropertyDrawer.OnGUI(new Rect(0, 0, 1000, height), m_Property, GUIContent.none);

                // Remove a locale
                var localeToRemove = m_FakeLocaleProvider.TestLocales[0];
                LocalizationEditorSettings.RemoveLocale(localeToRemove);
                Assert.That(m_FakeLocaleProvider.TestLocales, Does.Not.Contains(localeToRemove));

                // Update again, it should not contain the new element
                height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none);
                m_PropertyDrawer.OnGUI(new Rect(0, 0, 1000, height), m_Property, GUIContent.none);
                CheckListViewContainsProjectLocales();

                return(true);
            });

            yield return(null);

            Assert.That(window.TestCompleted, Is.True);
        }
示例#2
0
        static void RemoveSelectedLocale(ReorderableList list, int index)
        {
            var locale = list.List[index] as Locale;

            if (locale == null)
            {
                return;
            }

            LocalizationEditorSettings.RemoveLocale(locale, true);
        }
        void DrawToolbar(Rect rect)
        {
            var commandName = Event.current.commandName;
            var controlId   = GUIUtility.GetControlID(FocusType.Passive);

            var fieldPos  = EditorGUI.PrefixLabel(rect, GUIContent.none);
            var selection = (ToolBarChoices)GUI.Toolbar(fieldPos, -1, Styles.toolbarButtons);

            switch (selection)
            {
            case ToolBarChoices.LocaleGeneratorWindow:
                LocaleGeneratorWindow.ShowWindow();
                break;

            case ToolBarChoices.RemoveSelected:
            {
                var selectedLocales = ListView.GetSelection();
                for (int i = selectedLocales.Count - 1; i >= 0; --i)
                {
                    var item = ListView.GetRows()[selectedLocales[i]] as SerializedLocaleItem;
                    LocalizationEditorSettings.RemoveLocale(item.SerializedObject.targetObject as Locale, true);
                }
                ListView.SetSelection(new int[0]);
                ListView.Reload();
            }
            break;

            case ToolBarChoices.AddAsset:
                EditorGUIUtility.ShowObjectPicker <Locale>(null, false, string.Empty, controlId);
                break;

            case ToolBarChoices.AddAllAssets:
            {
                var assets = AssetDatabase.FindAssets("t:Locale");
                for (int i = 0; i < assets.Length; ++i)
                {
                    LocalizationEditorSettings.AddLocale(AssetDatabase.LoadAssetAtPath <Locale>(AssetDatabase.GUIDToAssetPath(assets[i])), true);
                }
                ListView.Reload();
            }
            break;
            }

            if (commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == controlId && EditorGUIUtility.GetObjectPickerObject() != null)
            {
                LocalizationEditorSettings.AddLocale(EditorGUIUtility.GetObjectPickerObject() as Locale, true);
                ListView.Reload();
            }
        }
示例#4
0
        public void ProjectLocalesIsUpdatedWhenRemoveLocaleIsUndone()
        {
            const string localeAssetPath = "Assets/HebrewRemove.asset";
            var          locale          = Locale.CreateLocale(SystemLanguage.Hebrew);

            AssetDatabase.CreateAsset(locale, localeAssetPath);
            LocalizationEditorSettings.AddLocale(locale, false);
            Assert.That(LocalizationEditorSettings.GetLocales(), Does.Contain(locale), "Expected new locale asset to be added to Project Locales.");

            LocalizationEditorSettings.RemoveLocale(locale, true);
            Assert.That(LocalizationEditorSettings.GetLocales(), Does.Not.Contains(locale), "Expected locale to not be in project locales after calling RemoveLocale.");

            Undo.PerformUndo();
            Assert.That(LocalizationEditorSettings.GetLocales(), Does.Contain(locale), "Expected locale asset to be in project locale after calling Undo.");

            AssetDatabase.DeleteAsset(localeAssetPath);
        }
        public IEnumerator ListViewUpdatesWhenLocaleIsRemoved()
        {
            WrapperWindow window = GetWindow((wnd) =>
            {
                // Remove a locale
                var localeToRemove = m_FakeLocaleProvider.TestLocales[0];
                LocalizationEditorSettings.RemoveLocale(localeToRemove);
                Assert.That(m_FakeLocaleProvider.TestLocales, Does.Not.Contains(localeToRemove));
                CheckListContainsProjectLocales(wnd);
                return(true);
            });

            var root = m_PropertyDrawer.CreatePropertyGUI(m_ScriptableObject.FindProperty("provider"));

            window.rootVisualElement.Add(root);

            yield return(null);

            Assert.That(window.TestCompleted, Is.True);
        }