public void OnLocalize() { #if UNITY_EDITOR var flags = text != null ? text.hideFlags : HideFlags.None; if (text != null) { text.hideFlags = HideFlags.DontSave; } #endif if (parameters != null && parameters.Count > 0) { SetText(text, MultiLanguage.GetFormat(key, parameters.ToArray())); } else { SetText(text, MultiLanguage.Get(key)); } var direction = MultiLanguage.Instance.SelectedLanguageDirection; if (text != null && !maintainTextAlignment) { UpdateAlignment(text, direction); } #if UNITY_EDITOR if (text != null) { text.hideFlags = flags; } #endif }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); EditorGUI.BeginChangeCheck(); var keyProperty = property; EditorGUI.PropertyField(position, keyProperty, label, true); var key = keyProperty.stringValue; var localizedString = MultiLanguage.Get(key); EditorGUILayout.LabelField("Localized Text", localizedString); if (!string.IsNullOrEmpty(key)) { if (!MultiLanguage.KeyExist(key)) { DrawAutoComplete(keyProperty); } } EditorGUI.EndProperty(); }
public void OnLocalize() { var flags = text.hideFlags; text.hideFlags = HideFlags.DontSave; text.text = MultiLanguage.Get(key); var direction = MultiLanguage.Instance.SelectedLanguageDirection; if (IsOppositeDirection(text.alignment, direction)) { switch (text.alignment) { case TextAlignment.Left: text.alignment = TextAlignment.Right; break; case TextAlignment.Right: text.alignment = TextAlignment.Left; break; } } text.hideFlags = flags; }
public void OnInspectorGUI(string propertyPath) { EditorGUI.BeginChangeCheck(); serializedObject.Update(); var iterator = serializedObject.GetIterator(); for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); if (iterator.name == propertyPath) { var key = iterator.stringValue; var localizedString = MultiLanguage.Get(key); EditorGUILayout.LabelField("Localized Text", localizedString); if (!string.IsNullOrEmpty(key)) { if (!MultiLanguage.KeyExist(key)) { DrawAutoComplete(iterator); } } } } serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { var text = target as T; if (text != null) { text.OnLocalize(); } } }