From 947cad00ccf5dc11e34716ab8096e95cefd8b046 Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Wed, 5 Feb 2025 15:34:32 +0100 Subject: [PATCH] UX improvements on table extension drawer --- Editor/PhraseExtensionPropertyDrawerData.cs | 31 ++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Editor/PhraseExtensionPropertyDrawerData.cs b/Editor/PhraseExtensionPropertyDrawerData.cs index 1b48e28..c24aef2 100644 --- a/Editor/PhraseExtensionPropertyDrawerData.cs +++ b/Editor/PhraseExtensionPropertyDrawerData.cs @@ -19,8 +19,13 @@ class TablePropertyDrawer : PropertyDrawer private Texture icon; + private float height = 0; + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { + var extension = property.GetActualObjectForSerializedProperty(fieldInfo); + var collection = extension.TargetCollection as StringTableCollection; + EditorGUI.BeginProperty(position, label, property); position.yMin += EditorGUIUtility.standardVerticalSpacing; position.height = EditorGUIUtility.singleLineHeight; @@ -35,10 +40,19 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten m_provider = property.FindPropertyRelative("m_provider"); EditorGUI.PropertyField(position, m_provider); position.y += position.height + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(position, m_identifierType); - position.y += position.height + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(position, m_identifier); + EditorGUI.PropertyField(position, m_identifierType, new GUIContent("Only keys matching", "Optionally, pull only keys matching the given prefix or tag.")); position.y += position.height + EditorGUIUtility.standardVerticalSpacing; + switch (extension.m_identifierType) + { + case TableIdentifierType.KeyPrefix: + EditorGUI.PropertyField(position, m_identifier, new GUIContent("Prefix", "Only keys with this prefix will be pulled. When pushed, all the keys from this table will be prefixed with this string")); + position.y += position.height + EditorGUIUtility.standardVerticalSpacing; + break; + case TableIdentifierType.Tag: + EditorGUI.PropertyField(position, m_identifier, new GUIContent("Tag Name", "Only keys with this tag will be pulled. When pushed, all the keys from this table will be tagged with this tag")); + position.y += position.height + EditorGUIUtility.standardVerticalSpacing; + break; + } if (m_provider.objectReferenceValue != null) { @@ -47,29 +61,26 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten var buttonWidth = position.width / 2 - EditorGUIUtility.standardVerticalSpacing; var buttonPosition = position; buttonPosition.width = buttonWidth; - if (GUI.Button(buttonPosition, "Push")) + if (GUI.Button(buttonPosition, new GUIContent($"Push {provider.LocaleIdsToPush.Count} locale(s)", "Push the table content to Phrase"))) { - var extension = property.GetActualObjectForSerializedProperty(fieldInfo); - var collection = extension.TargetCollection as StringTableCollection; EditorCoroutineUtility.StartCoroutineOwnerless(provider.PushAll(new List { collection })); } buttonPosition.x += buttonWidth + EditorGUIUtility.standardVerticalSpacing; - if (GUI.Button(buttonPosition, "Pull")) + if (GUI.Button(buttonPosition, new GUIContent($"Pull {provider.LocaleIdsToPull.Count} locale(s)", "Pull the table content from Phrase"))) { - var extension = property.GetActualObjectForSerializedProperty(fieldInfo); - var collection = extension.TargetCollection as StringTableCollection; EditorCoroutineUtility.StartCoroutineOwnerless(provider.Pull(new List { collection })); } position.y += position.height + EditorGUIUtility.standardVerticalSpacing; } } + height = position.y; EditorGUI.EndProperty(); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { - return EditorGUIUtility.singleLineHeight * 5 + EditorGUIUtility.standardVerticalSpacing * 2; + return height; } } } \ No newline at end of file