private void AddLocale(LocalizedAssetBase localizedAsset) { if (LocalizedAssetEditor.AddLocale(localizedAsset)) { m_TreeView.Reload(); } }
private void RemoveLocale(LocalizedAssetBase localizedAsset, LocaleItemBase localeItem) { if (LocalizedAssetEditor.RemoveLocale(localizedAsset, localeItem)) { m_TreeView.Reload(); } }
/// <summary> /// Adds a locale and the value or updates if specified language is exists. /// </summary> public static bool AddOrUpdateLocale(LocalizedAssetBase localizedAsset, Language language, object value) { var serializedObject = new SerializedObject(localizedAsset); serializedObject.Update(); var elements = serializedObject.FindLocaleItemsProperty(); if (elements != null && elements.arraySize > 0) { var index = Array.FindIndex(localizedAsset.LocaleItems, x => x.Language == language); if (index < 0) { AddLocale(localizedAsset); index = localizedAsset.LocaleItems.Length - 1; } var localeItem = localizedAsset.LocaleItems[index]; localeItem.Language = language; localeItem.ObjectValue = value; return(true); } return(false); }
private void AddLocale(LocalizedAssetBase localizedAsset) { var serializedObject = new SerializedObject(localizedAsset); serializedObject.Update(); var elements = serializedObject.FindProperty(LocalizationEditorHelper.LocalizedElementsSerializedProperty); if (elements != null) { elements.arraySize += 1; serializedObject.ApplyModifiedProperties(); m_TreeView.Reload(); } }
private void RemoveLocale(LocalizedAssetBase localizedAsset, LocaleItemBase localeItem) { var serializedObject = new SerializedObject(localizedAsset); serializedObject.Update(); var elements = serializedObject.FindProperty(LocalizationEditorHelper.LocalizedElementsSerializedProperty); if (elements != null && elements.arraySize > 1) { var localeItemIndex = Array.IndexOf(localizedAsset.LocaleItems, localeItem); elements.DeleteArrayElementAtIndex(localeItemIndex); serializedObject.ApplyModifiedProperties(); m_TreeView.Reload(); } }
/// <summary> /// Adds a locale end of the list by copying last one. /// </summary> public static bool AddLocale(LocalizedAssetBase localizedAsset) { var serializedObject = new SerializedObject(localizedAsset); serializedObject.Update(); var elements = serializedObject.FindLocaleItemsProperty(); if (elements != null) { elements.arraySize += 1; serializedObject.ApplyModifiedProperties(); return(true); } return(false); }
private void MakeLocaleDefault(LocalizedAssetBase localizedAsset, LocaleItemBase localeItem) { var serializedObject = new SerializedObject(localizedAsset); serializedObject.Update(); var elements = serializedObject.FindProperty(LocalizationEditorHelper.LocalizedElementsSerializedProperty); if (elements != null && elements.arraySize > 1) { var defaultLanguage = localeItem.Language; var localeItemIndex = Array.IndexOf(localizedAsset.LocaleItems, localeItem); elements.MoveArrayElement(localeItemIndex, 0); serializedObject.ApplyModifiedProperties(); m_TreeView.Reload(); Debug.Log(localizedAsset.name + ":" + defaultLanguage + " was set as the default language."); } }
private void TranslateMissingLocales(LocalizedAssetBase localizedAsset) { m_Translator = new GoogleTranslator(LocalizationSettings.Instance.GoogleAuthenticationFile); var localizedText = localizedAsset as LocalizedText; var options = new List <GUIContent>(); foreach (var locale in localizedText.TypedLocaleItems) { if (!string.IsNullOrEmpty(locale.Value)) { options.Add(new GUIContent(locale.Language.ToString())); } } var mousePosition = Event.current.mousePosition; var popupPosition = new Rect(mousePosition.x, mousePosition.y, 0, 0); EditorUtility.DisplayCustomMenu(popupPosition, options.ToArray(), -1, TranslateSelected, localizedText); }
/// <summary> /// Removes specified locale item from the list. /// </summary> public static bool RemoveLocale(LocalizedAssetBase localizedAsset, LocaleItemBase localeItem) { var serializedObject = new SerializedObject(localizedAsset); serializedObject.Update(); var elements = serializedObject.FindLocaleItemsProperty(); if (elements != null && elements.arraySize > 1) { var index = Array.IndexOf(localizedAsset.LocaleItems, localeItem); if (index >= 0) { elements.DeleteArrayElementAtIndex(index); serializedObject.ApplyModifiedProperties(); return(true); } } return(false); }
public AssetTreeViewItem(int depth, LocalizedAssetBase data) : base(data.GetInstanceID(), depth, data.name) { LocalizedAsset = data; }