SerializableLocalizationObjectPair DrawRootPair(Rect position, SerializableLocalizationObjectPair item) { LocalizedObjectType newChangedType = (LocalizedObjectType)EditorGUI.Popup( listColumns.GetColumnPosition(position, "Type"), (int)item.changedValue.ObjectType, keyTypes); int index = changedRootValues.IndexOf(item); SerializableStringPair rootValue = changedRootKeys[index]; string newChangedValue = EditorGUI.TextField(listColumns.GetColumnPosition(position, "Key"), rootValue.changedValue); string newTextValue = EditorGUI.TextArea(listColumns.GetColumnPosition(position, "Comment"), item.changedValue.TextValue); if (newChangedType != changedRootValues[index].changedValue.ObjectType || newChangedValue != rootValue.changedValue || newTextValue != changedRootValues[index].changedValue.TextValue) { undoManager.ForceDirty(); changedRootValues[index].changedValue.ObjectType = newChangedType; rootValue.changedValue = newChangedValue; changedRootValues[index].changedValue.TextValue = newTextValue; } return(item); }
SerializableLocalizationObjectPair DrawLanguageValue(Rect position, SerializableLocalizationObjectPair item) { float fullWindowWidth = position.width + 28; position.width = fullWindowWidth; if (GUI.Button(listColumns.GetColumnPosition(position, "Copy"), "Copy Root")) { if (undoManager != null) { undoManager.ForceDirty(); } item.changedValue = new LocalizedObject(rootValues[item.keyValue]); GUIUtility.keyboardControl = 0; } if (item.changedValue.ObjectType == LocalizedObjectType.STRING && canLanguageBeTranslated && translateFromLanguageValue != 0 && translateFromDictionary != null && translateFromDictionary[item.keyValue].TextValue != null && translateFromDictionary[item.keyValue].TextValue != string.Empty) { if (GUI.Button(listColumns.GetColumnPosition(position, "Translate"), "Translate")) { automaticTranslator.TranslateText(OnTextTranslated, item.keyValue, translateFromDictionary[item.keyValue].TextValue, translateFromLanguage, currentCultureInfo.languageCode); } } else { GUI.Label(listColumns.GetColumnPosition(position, "Translate"), "Translate"); } EditorGUI.SelectableLabel(listColumns.GetColumnPosition(position, "Key"), item.keyValue); EditorGUI.SelectableLabel(listColumns.GetColumnPosition(position, "Comment"), rootValues[item.keyValue].TextValue); if (item.changedValue.ObjectType != LocalizedObjectType.STRING && otherAvailableLanguageCodes.Count > 0) { bool overrideLang = EditorGUI.Toggle(listColumns.GetColumnPosition(position, "Override"), item.changedValue.OverrideLocalizedObject); if (overrideLang != item.changedValue.OverrideLocalizedObject) { if (undoManager != null) { undoManager.ForceDirty(); } item.changedValue.OverrideLocalizedObject = overrideLang; if (overrideLang) { item.changedValue.OverrideObjectLanguageCode = otherAvailableLanguageCodes[0]; } } } else { GUI.Label(listColumns.GetColumnPosition(position, "Override"), "-"); } Rect newPosition = listColumns.GetColumnPosition(position, "Value"); bool setDirty = false; if (!item.changedValue.OverrideLocalizedObject) { if (item.changedValue.ObjectType == LocalizedObjectType.STRING) { string newTextValue = EditorGUI.TextArea(newPosition, item.changedValue.TextValue); if (newTextValue != item.changedValue.TextValue) { setDirty = true; item.changedValue.TextValue = newTextValue; } } else if (item.changedValue.ObjectType == LocalizedObjectType.AUDIO) { AudioClip newAudioValue = (AudioClip)EditorGUI.ObjectField(newPosition, item.changedValue.ThisAudioClip, typeof(AudioClip), false); if (newAudioValue != item.changedValue.ThisAudioClip) { setDirty = true; item.changedValue.ThisAudioClip = newAudioValue; } } else if (item.changedValue.ObjectType == LocalizedObjectType.GAME_OBJECT) { GameObject newGameObjectValue = (GameObject)EditorGUI.ObjectField(newPosition, item.changedValue.ThisGameObject, typeof(GameObject), false); if (newGameObjectValue != item.changedValue.ThisGameObject) { setDirty = true; item.changedValue.ThisGameObject = newGameObjectValue; } } else if (item.changedValue.ObjectType == LocalizedObjectType.TEXTURE) { Texture newTextureValue = (Texture)EditorGUI.ObjectField(newPosition, item.changedValue.ThisTexture, typeof(Texture), false); if (newTextureValue != item.changedValue.ThisTexture) { setDirty = true; item.changedValue.ThisTexture = newTextureValue; } } else if (item.changedValue.ObjectType == LocalizedObjectType.TEXT_ASSET) { TextAsset newTextAssetValue = (TextAsset)EditorGUI.ObjectField(newPosition, item.changedValue.ThisTextAsset, typeof(TextAsset), false); if (newTextAssetValue != item.changedValue.ThisTextAsset) { setDirty = true; item.changedValue.ThisTextAsset = newTextAssetValue; } } else if (item.changedValue.ObjectType == LocalizedObjectType.FONT) { Font newFontValue = (Font)EditorGUI.ObjectField(newPosition, item.changedValue.Font, typeof(Font), false); if (newFontValue != item.changedValue.Font) { setDirty = true; item.changedValue.Font = newFontValue; } } } else { if (otherAvailableLanguageCodes.Count > 0) { int selectedIndex = -1; for (int i = 0; i < otherAvailableLanguageCodes.Count; ++i) { if (otherAvailableLanguageCodes[i] == item.changedValue.OverrideObjectLanguageCode) { selectedIndex = i; break; } } if (selectedIndex == -1) { selectedIndex = 0; item.changedValue.OverrideObjectLanguageCode = otherAvailableLanguageCodes[selectedIndex]; setDirty = true; } int newIndex = EditorGUI.Popup(newPosition, selectedIndex, otherAvailableLanguageCodesArray); if (newIndex != selectedIndex) { item.changedValue.OverrideObjectLanguageCode = otherAvailableLanguageCodes[newIndex]; setDirty = true; } } else { //There are no languages to steal from, disable the override. item.changedValue.OverrideLocalizedObject = false; setDirty = true; } } if (undoManager != null && setDirty) { undoManager.ForceDirty(); } return(item); }