public TableCreator() { var asset = Resources.GetTemplateAsset(nameof(TableCreator)); asset.CloneTree(this); var locales = LocalizationEditorSettings.GetLocales(); m_LocalesList = this.Q <ScrollView>("locales-list"); foreach (var locale in locales) { AddLocaleElement(locale); } m_CreateStringTablesButton = this.Q <Button>("create-string-tables-button"); m_CreateStringTablesButton.clickable.clicked += () => CreateCollection(LocalizationEditorSettings.CreateStringTableCollection); m_CreateAssetTablesButton = this.Q <Button>("create-asset-tables-button"); m_CreateAssetTablesButton.clickable.clicked += () => CreateCollection(LocalizationEditorSettings.CreateAssetTableCollection); UpdateCreateButtonState(); this.Q <Button>("select-all-button").clickable.clicked += () => SelectAllLocales(true); this.Q <Button>("select-none-button").clickable.clicked += () => SelectAllLocales(false); this.Q <Button>("locale-generator-button").clickable.clicked += () => LocaleGeneratorWindow.ShowWindow(); m_TableCollectionName = this.Q <TextField>("new-table-name-field"); LocalizationEditorSettings.EditorEvents.LocaleAdded += OnLocaleAdded; LocalizationEditorSettings.EditorEvents.LocaleRemoved += OnLocaleRemoved; }
void OnEnable() { m_ActiveSettingsRoot = new VisualElement(); rootVisualElement.Add(m_ActiveSettingsRoot); rootVisualElement.Add(new IMGUIContainer(() => { if (LocalizationEditorSettings.ActiveLocalizationSettings == null) { EditorGUILayout.HelpBox("Project contains no Localization Settings. Please create one via `Edit/Project Settings/Localization`", MessageType.Info); } m_ActiveSettingsRoot.style.display = LocalizationEditorSettings.ActiveLocalizationSettings == null ? DisplayStyle.None : DisplayStyle.Flex; })); var template = Resources.GetTemplateAsset(nameof(SceneControlsWindow)); template.CloneTree(m_ActiveSettingsRoot); m_ProjectLocale = m_ActiveSettingsRoot.Q <ProjectLocalePopupField>(); m_ProjectLocale.RegisterValueChangedCallback(evt => { InternalEditorUtility.RepaintAllViews(); // In order for UGUI components to update themselves we need to tell the component it is dirty with SetAllDirty and then force the player loop to run. // This method allows us to queue a player loop update regardless of whether the Scene has been marked dirty. EditorApplication.QueuePlayerLoopUpdate(); // Force the scene to update }); Undo.postprocessModifications += PostprocessModifications; Undo.undoRedoPerformed += LocalizationEditorSettings.RefreshEditorPreview; }
public EditAssetTables() { var asset = Resources.GetTemplateAsset(nameof(EditAssetTables)); asset.CloneTree(this); m_TableContents = this.Q("table-contents"); m_AssetTablesField = this.Q <ProjectTablesPopup>(); m_AssetTablesField.RegisterValueChangedCallback((evt) => TableCollectionSelected(evt.newValue)); TableCollectionSelected(m_AssetTablesField.value); }
static void CreateItem(ReorderableList list, int index, VisualElement root) { var locale = list.List[index] as Locale; var so = new SerializedObject(locale); var asset = Resources.GetTemplateAsset("LocalesProviderItem"); asset.CloneTree(root); root.Query <TextField>().ForEach(tf => tf.isDelayed = true); root.Bind(so); }
public virtual void OnEnable() { Undo.undoRedoPerformed += UndoRedoPerformed; var asset = Resources.GetTemplateAsset(GetType().Name); asset.CloneTree(this); m_TableContentsPanel = this.Q("table-contents-panel"); m_PropertiesPanel = this.Q("properties-panel"); m_NameField = this.Q <TextField>("table-name-field"); m_NameField.value = TableCollection.TableCollectionName; m_NameField.RegisterCallback <ChangeEvent <string> >(TableCollectionNameChanged); m_NameField.isDelayed = true; // Prevent an undo per char change. }
public TableCreator() { var asset = Resources.GetTemplateAsset(nameof(TableCreator)); asset.CloneTree(this); var locales = LocalizationEditorSettings.GetLocales(); m_LocalesList = this.Q <ScrollView>("locales-list"); foreach (var locale in locales) { AddLocaleElement(locale); } m_LocaleHelpBoxContainer = this.Q("locale-help-box-container"); var items = new List <Type> { typeof(StringTableCollection), typeof(AssetTableCollection) }; m_CollectionTypeContainer = this.Q <VisualElement>("table-collection-type-container"); m_CollectionTypePopup = new PopupField <Type>("Type", items, 0) { formatListItemCallback = type => ObjectNames.NicifyVariableName(type.Name), formatSelectedValueCallback = type => ObjectNames.NicifyVariableName(type.Name) }; m_CollectionTypePopup.RegisterValueChangedCallback(it => UpdateCreateButtonState()); m_CollectionTypeContainer.Add(m_CollectionTypePopup); m_CreateTableCollectionButton = this.Q <Button>("create-table-collection-button"); m_CreateTableCollectionButton.clickable.clicked += CreateCollection; this.Q <Button>("select-all-button").clickable.clicked += () => SelectAllLocales(true); this.Q <Button>("select-none-button").clickable.clicked += () => SelectAllLocales(false); this.Q <Button>("locale-generator-button").clickable.clicked += () => LocaleGeneratorWindow.ShowWindow(); m_TableCollectionName = this.Q <TextField>("new-table-name-field"); m_TableCollectionName.RegisterValueChangedCallback(it => UpdateCreateButtonState()); InitializeTableName(); m_TableNameHelpBoxContainer = this.Q("table-name-help-box-container"); LocalizationEditorSettings.EditorEvents.LocaleAdded += OnLocaleAdded; LocalizationEditorSettings.EditorEvents.LocaleRemoved += OnLocaleRemoved; }
public ProjectCollectionsTableSelector() { var asset = Resources.GetTemplateAsset(nameof(ProjectCollectionsTableSelector)); asset.CloneTree(this); m_ContentContainer = this.Q("select-list"); var searchField = this.Q <ToolbarSearchField>("search-field"); searchField.RegisterValueChangedCallback(SearchChanged); var selectAllButton = this.Q <Button>("select-all-button"); selectAllButton.clicked += () => SelectVisible(true); var selectNoneButton = this.Q <Button>("select-none-button"); selectNoneButton.clicked += () => SelectVisible(false); Initialize(); }
public void OnEnable() { m_root = rootVisualElement; // Import UXML var asset = Resources.GetTemplateAsset(nameof(CustomLocaleUIWindow)); asset.CloneTree(m_root); var localeName = m_root.Q <TextField>("customLocaleUI_localeName"); var localeIdentifier = m_root.Q <TextField>("customLocaleUI_localeIdentifier"); localeIdentifier.RegisterValueChangedCallback(evt => { var enableCreateBTN = true; var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); var locales = LocalizationEditorSettings.GetLocales(); var localeIDName = localeIdentifier.value; foreach (var culture in cultures) { if (culture.Name == localeIdentifier.value && localeIdentifier.value.Length > 1) { enableCreateBTN = false; localeIDName = culture.ToString(); } } for (int i = 0; i < (int)SystemLanguage.Unknown; ++i) { var localeID = new LocaleIdentifier((SystemLanguage)i); if (localeID.Code == localeIdentifier.value && localeIdentifier.value.Length > 1) { enableCreateBTN = false; localeIDName = localeID.ToString(); } } foreach (var availableLocale in locales) { if (availableLocale.Identifier.Code == localeIdentifier.value && localeIdentifier.value.Length > 1) { enableCreateBTN = false; localeIDName = availableLocale.name; } } m_createButton.SetEnabled(enableCreateBTN); if (!enableCreateBTN) { if (m_helpBox == null) { AddHelpInfo(localeIDName); } } else { if (m_helpBox != null) { m_root.Remove(m_helpBox); m_helpBox = null; } } }); m_createButton = m_root.Q <Button>("customLocaleUI_CreateBTN"); m_createButton.clickable.clicked += () => { CreateCustomLocale(localeName.value, localeIdentifier.value); }; }