public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); SerializedProperty spContent = property.FindPropertyRelative("content"); SerializedProperty spPostProcess = property.FindPropertyRelative("postProcess"); SerializedProperty spTranslationID = property.FindPropertyRelative("translationID"); bool translationOn = spTranslationID.intValue != 0; Rect btnRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); bool nextTranslationOn = EditorGUI.Toggle(btnRect, GUICONTENT_TRANSLATION, translationOn); if (translationOn != nextTranslationOn) { if (nextTranslationOn) { spTranslationID.intValue = LocStringPropertyDrawer.GenerateID(); Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); ((DatabaseLocalizationEditor)editorLocalization).AddTranslation(spTranslationID.intValue, spContent.stringValue); } else { if (spTranslationID.intValue != 0) { Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); ((DatabaseLocalizationEditor)editorLocalization).RemoveTranslation(spTranslationID.intValue); } spTranslationID.intValue = 0; } } if (spTranslationID.intValue != 0) { if (this.spDatabasePlaceholder == null) { Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); this.spDatabasePlaceholder = ((DatabaseLocalizationEditor)editorLocalization).GetPlaceholder( spTranslationID.intValue ); } if (this.spDatabasePlaceholder != null) { this.spDatabasePlaceholder.stringValue = spContent.stringValue; this.spDatabasePlaceholder.serializedObject.ApplyModifiedProperties(); } } EditorGUILayout.PropertyField(spPostProcess); property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); SerializedProperty spContent = property.FindPropertyRelative("content"); SerializedProperty spPostProcess = property.FindPropertyRelative("postProcess"); SerializedProperty spTranslationID = property.FindPropertyRelative("translationID"); Rect spContentRect = new Rect( position.x, position.y, position.width - TRANSLATION_BUTTON_WIDTH - HORIZONTAL_SEPARATION, position.height ); Rect spTranslationIDRect = new Rect( spContentRect.x + spContentRect.width + HORIZONTAL_SEPARATION, position.y, TRANSLATION_BUTTON_WIDTH, position.height ); EditorGUI.PropertyField(spContentRect, spContent, label); GUIStyle translationStyle = (spTranslationID.intValue == 0 ? CoreGUIStyles.GetGridButtonRightOff() : CoreGUIStyles.GetGridButtonRightOn() ); if (GUI.Button(spTranslationIDRect, GUICONTENT_TRANSLATION, translationStyle)) { if (spTranslationID.intValue == 0) { spTranslationID.intValue = LocStringPropertyDrawer.GenerateID(); Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); ((DatabaseLocalizationEditor)editorLocalization).AddTranslation(spTranslationID.intValue, spContent.stringValue); } else { if (spTranslationID.intValue != 0) { Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); ((DatabaseLocalizationEditor)editorLocalization).RemoveTranslation(spTranslationID.intValue); } spTranslationID.intValue = 0; } } if (spTranslationID.intValue != 0) { if (this.spDatabasePlaceholder == null) { Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); this.spDatabasePlaceholder = ((DatabaseLocalizationEditor)editorLocalization).GetPlaceholder( spTranslationID.intValue ); } if (this.spDatabasePlaceholder != null) { this.spDatabasePlaceholder.stringValue = spContent.stringValue; this.spDatabasePlaceholder.serializedObject.ApplyModifiedProperties(); } } if (this.PaintPostProcess()) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(spPostProcess); EditorGUI.indentLevel--; } property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); SerializedProperty spContent = property.FindPropertyRelative("content"); SerializedProperty spPostProcess = property.FindPropertyRelative("postProcess"); SerializedProperty spTranslationID = property.FindPropertyRelative("translationID"); Rect spTranslationIDRect = new Rect( position.x, position.y, position.width, EditorGUIUtility.singleLineHeight ); bool translationOn = spTranslationID.intValue != 0; bool nextTranslationOn = EditorGUI.Toggle(spTranslationIDRect, GUICONTENT_TRANSLATION, translationOn); if (this.PaintPostProcess()) { EditorGUILayout.PropertyField(spPostProcess); } if (this.textAreaStyle == null) { this.textAreaStyle = new GUIStyle(EditorStyles.textArea); // this.textAreaStyle.margin = new RectOffset(5, 5, 0, 0); this.textAreaStyle.wordWrap = true; } Rect textAreaRect = GUILayoutUtility.GetRect( EditorGUIUtility.fieldWidth, EditorGUIUtility.fieldWidth, EditorGUIUtility.singleLineHeight * 3f, EditorGUIUtility.singleLineHeight * 3f, this.textAreaStyle ); spContent.stringValue = EditorGUI.TextArea( textAreaRect, spContent.stringValue, this.textAreaStyle ); if (translationOn != nextTranslationOn) { if (nextTranslationOn) { spTranslationID.intValue = LocStringPropertyDrawer.GenerateID(); Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); ((DatabaseLocalizationEditor)editorLocalization).AddTranslation(spTranslationID.intValue, spContent.stringValue); } else { if (spTranslationID.intValue != 0) { Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); ((DatabaseLocalizationEditor)editorLocalization).RemoveTranslation(spTranslationID.intValue); } spTranslationID.intValue = 0; } } if (spTranslationID.intValue != 0) { if (this.spDatabasePlaceholder == null) { Editor editorLocalization = DatabaseLocalizationEditor.CreateEditor(DatabaseLocalization.Load()); this.spDatabasePlaceholder = ((DatabaseLocalizationEditor)editorLocalization).GetPlaceholder( spTranslationID.intValue ); } if (this.spDatabasePlaceholder != null) { this.spDatabasePlaceholder.stringValue = spContent.stringValue; this.spDatabasePlaceholder.serializedObject.ApplyModifiedProperties(); } } property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); }