public void SetAsset(TObject asset, AddressableAssetTableT <TObject> table) { var oldAsset = GetAsset(table); if (oldAsset != null) { LocalizationAddressableSettings.RemoveAssetFromTable(table, Key, asset); } if (asset != null) { LocalizationAddressableSettings.AddAssetToTable(table, Key, asset as TObject); } // Update cache var foundIndex = m_Assets.FindIndex(o => o.Key == table.LocaleIdentifier.Code); if (foundIndex == -1) { m_Assets.Add(new KeyValuePair <string, TObject>(table.LocaleIdentifier.Code, asset)); } else { m_Assets[foundIndex] = new KeyValuePair <string, TObject>(table.LocaleIdentifier.Code, asset); } }
protected virtual void InitializeColumns() { showBorder = true; showAlternatingRowBackgrounds = true; var columns = new MultiColumnHeaderState.Column[Tables.Count + 1]; columns[0] = new MultiColumnHeaderState.Column() { headerContent = new GUIContent("Key"), headerTextAlignment = TextAlignment.Center, canSort = true, allowToggleVisibility = false, sortedAscending = true }; // Update column labels if possible var locales = LocalizationAddressableSettings.GetLocales(); for (int i = 0; i < Tables.Count; ++i) { var foundLocale = locales.FirstOrDefault(o => o.Identifier.Code == Tables[i].LocaleIdentifier.Code); columns[i + 1] = new MultiColumnHeaderState.Column() { headerContent = new GUIContent(foundLocale != null ? foundLocale.name : Tables[i].LocaleIdentifier.Code), headerTextAlignment = TextAlignment.Center, canSort = false, // TODO: Support sorting allowToggleVisibility = true, }; } var multiColState = new MultiColumnHeaderState(columns); multiColumnHeader = new MultiColumnHeader(multiColState); multiColumnHeader.ResizeToFit(); }
protected void UpdateAddressable() { // Updates the addressables version so it has the correct label and address, such as if the locale or name was changed. if (targets != null && targets.Length > 0) { foreach (var t in targets) { LocalizationAddressableSettings.AddOrUpdateAssetTable((LocalizedTable)t); } } else { LocalizationAddressableSettings.AddOrUpdateAssetTable((LocalizedTable)target); } }
protected override TreeViewItem BuildRoot() { TreeViewItem root = new TreeViewItem(-1, -1, "root"); var items = new List <TreeViewItem>(); foreach (var l in LocalizationAddressableSettings.GetLocales()) { items.Add(new SerializedLocaleItem(l)); } ApplySorting(items); for (int i = 0; i < items.Count; ++i) { items[i].id = i; } SetupParentsAndChildrenFromDepths(root, items); return(root); }
void DrawToolbar() { string commandName = Event.current.commandName; int controlId = GUIUtility.GetControlID(FocusType.Passive); var selection = (ToolBarChoices)GUILayout.Toolbar(-1, s_Texts.toolbarButtons, EditorStyles.toolbarButton); switch (selection) { case ToolBarChoices.LocaleGeneratorWindow: LocaleGeneratorWindow.ShowWindow((locale) => { LocalizationAddressableSettings.AddLocale(locale); Reset(); }); break; case ToolBarChoices.RemoveSelected: { var selectedLocales = m_ListView.GetSelection(); for (int i = selectedLocales.Count - 1; i >= 0; --i) { var item = m_ListView.GetRows()[selectedLocales[i]] as SerializedLocaleItem; LocalizationAddressableSettings.RemoveLocale(item.SerializedObject.targetObject as Locale); } m_ListView.SetSelection(new int[0]); m_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) { LocalizationAddressableSettings.AddLocale(AssetDatabase.LoadAssetAtPath <Locale>(AssetDatabase.GUIDToAssetPath(assets[i]))); } m_ListView.Reload(); } break; } // Selected Locale if (m_ListView.GetSelection().Count == 1) { if (m_SelectedLocaleEditor == null || m_SelectedLocaleIndex != m_ListView.GetSelection()[0]) { m_SelectedLocaleIndex = m_ListView.GetSelection()[0]; var item = m_ListView.GetRows()[m_SelectedLocaleIndex] as SerializedLocaleItem; CreateCachedEditor(item.SerializedObject.targetObjects, null, ref m_SelectedLocaleEditor); } EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField(s_Texts.localeDetails); EditorGUI.indentLevel++; m_SelectedLocaleEditor.OnInspectorGUI(); EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); } if (commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == controlId && EditorGUIUtility.GetObjectPickerObject() != null) { LocalizationAddressableSettings.AddLocale(EditorGUIUtility.GetObjectPickerObject() as Locale); m_ListView.Reload(); } }