Skip to content

Commit aee719b

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@3.2.0-pre.7
## [3.2.0-pre.7] - 2023-12-17 ### Changes - Fixed TMP_InputField line limit behavior to mean unlimited when the value is set to zero or negative (UUM-57192) - Fixed custom validator ignores the returned character from the validate function (UUM-42147) - Fixed editing a textfield on mobile and then submitting throws an exception (UUM-37282) - Addressed issue surrounding dropdown not closing correctly in certain situations(UUM-33691) - Ensure Sprites can be reordered within a SpriteAsset. (UUM-49349) - Added missing grey and lightblue tags (UUM-54820) - Fix underline when use at end of text. (UUM-55135) - Add support for Visions OS keyboard.
1 parent 83ba776 commit aee719b

15 files changed

+117
-45
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# Changelog
22
These are the release notes for the TextMesh Pro UPM package which was first introduced with Unity 2018.1. Please see the following link for the Release Notes for prior versions of TextMesh Pro. http://digitalnativestudios.com/forum/index.php?topic=1363.0
33

4+
5+
## [3.2.0-pre.7] - 2023-12-17
6+
### Changes
7+
- Fixed TMP_InputField line limit behavior to mean unlimited when the value is set to zero or negative (UUM-57192)
8+
- Fixed custom validator ignores the returned character from the validate function (UUM-42147)
9+
- Fixed editing a textfield on mobile and then submitting throws an exception (UUM-37282)
10+
- Addressed issue surrounding dropdown not closing correctly in certain situations(UUM-33691)
11+
- Ensure Sprites can be reordered within a SpriteAsset. (UUM-49349)
12+
- Added missing grey and lightblue tags (UUM-54820)
13+
- Fix underline when use at end of text. (UUM-55135)
14+
- Add support for Visions OS keyboard.
15+
416
## [3.2.0-pre.6] - 2023-09-25
517
### Changes
618
- Fix TextMeshPro component does not perform linear color conversion when the VertexColorAlwaysGammaSpace option is enabled. Case #UUM-36113

Scripts/Editor/TMP_BaseEditorPanel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,13 +1132,13 @@ protected void DrawMargins()
11321132
{
11331133
// Value range check on margins to make sure they are not excessive.
11341134
Vector4 margins = m_MarginProp.vector4Value;
1135-
Vector2 textContainerSize = m_RectTransform.sizeDelta;
1135+
Rect textContainerSize = m_RectTransform.rect;
11361136

1137-
margins.x = Mathf.Clamp(margins.x, -textContainerSize.x, textContainerSize.x);
1138-
margins.z = Mathf.Clamp(margins.z, -textContainerSize.x, textContainerSize.x);
1137+
margins.x = Mathf.Clamp(margins.x, -textContainerSize.width, textContainerSize.width);
1138+
margins.z = Mathf.Clamp(margins.z, -textContainerSize.width, textContainerSize.width);
11391139

1140-
margins.y = Mathf.Clamp(margins.y, -textContainerSize.y, textContainerSize.y);
1141-
margins.w = Mathf.Clamp(margins.w, -textContainerSize.y, textContainerSize.y);
1140+
margins.y = Mathf.Clamp(margins.y, -textContainerSize.height, textContainerSize.height);
1141+
margins.w = Mathf.Clamp(margins.w, -textContainerSize.height, textContainerSize.height);
11421142

11431143
m_MarginProp.vector4Value = margins;
11441144

Scripts/Editor/TMP_EditorResourceManager.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,13 @@ void OnPreRenderCanvases()
103103
}
104104

105105
#if UNITY_2023_3_OR_NEWER
106-
void OnEndOfFrame(ScriptableRenderContext renderContext, List<Camera> cameras)
107-
{
108-
DoPostRenderUpdates();
109-
}
106+
void OnEndOfFrame(ScriptableRenderContext renderContext, List<Camera> cameras)
110107
#else
111-
void OnEndOfFrame(ScriptableRenderContext renderContext, Camera[] cameras)
108+
void OnEndOfFrame(ScriptableRenderContext renderContext, Camera[] cameras)
109+
#endif
112110
{
113111
DoPostRenderUpdates();
114112
}
115-
#endif
116113

117114
/// <summary>
118115
/// Register resource for re-import.

Scripts/Editor/TMP_FontAssetEditor.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,11 @@ public void OnEnable()
312312
// Create serialized object to allow us to use a serialized property of an empty kerning pair.
313313
m_SerializedPropertyHolder = CreateInstance<TMP_SerializedPropertyHolder>();
314314
m_SerializedPropertyHolder.fontAsset = m_fontAsset;
315-
using (SerializedObject internalSerializedObject = new SerializedObject(m_SerializedPropertyHolder))
316-
{
317-
m_FirstCharacterUnicode_prop = internalSerializedObject.FindProperty("firstCharacter");
318-
m_SecondCharacterUnicode_prop = internalSerializedObject.FindProperty("secondCharacter");
319-
m_EmptyGlyphPairAdjustmentRecord_prop = internalSerializedObject.FindProperty("glyphPairAdjustmentRecord");
320-
}
315+
SerializedObject internalSerializedObject = new SerializedObject(m_SerializedPropertyHolder);
316+
m_FirstCharacterUnicode_prop = internalSerializedObject.FindProperty("firstCharacter");
317+
m_SecondCharacterUnicode_prop = internalSerializedObject.FindProperty("secondCharacter");
318+
m_EmptyGlyphPairAdjustmentRecord_prop = internalSerializedObject.FindProperty("glyphPairAdjustmentRecord");
319+
321320
m_materialPresets = TMP_EditorUtility.FindMaterialReferences(m_fontAsset);
322321

323322
m_GlyphSearchList = new List<int>();

Scripts/Editor/TMP_FontAsset_CreationMenu.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace TMPro
1212
{
1313
static class TMP_FontAsset_CreationMenu
1414
{
15-
[MenuItem("Assets/Create/TextMeshPro/FontAsset/Font Asset Variant", false, 200)]
15+
[MenuItem("Assets/Create/TextMeshPro/Font Asset/Font Asset Variant", false, 200)]
1616
static void CreateFontAssetVariant()
1717
{
1818
Object target = Selection.activeObject;
@@ -56,21 +56,21 @@ static void CreateFontAssetVariant()
5656
AssetDatabase.SaveAssets();
5757
}
5858

59-
[MenuItem("Assets/Create/TextMeshPro/FontAsset/SDF #%F12", false, 100)]
59+
[MenuItem("Assets/Create/TextMeshPro/Font Asset/SDF #%F12", false, 100)]
6060
//[MenuItem("Assets/Create/TextMeshPro/Font Asset", false, 100)]
6161
static void CreateFontAssetSDF()
6262
{
6363
CreateFontAsset(GlyphRenderMode.SDFAA);
6464
}
6565

66-
[MenuItem("Assets/Create/TextMeshPro/FontAsset/Bitmap", false, 105)]
66+
[MenuItem("Assets/Create/TextMeshPro/Font Asset/Bitmap", false, 105)]
6767
static void CreateFontAssetBitmap()
6868
{
6969
CreateFontAsset(GlyphRenderMode.SMOOTH);
7070
}
7171

7272
#if TEXTCORE_FONT_ENGINE_1_5_OR_NEWER
73-
[MenuItem("Assets/Create/TextMeshPro/FontAsset/Color", false, 110)]
73+
[MenuItem("Assets/Create/TextMeshPro/Font Asset/Color", false, 110)]
7474
static void CreateFontAssetColor()
7575
{
7676
CreateFontAsset(GlyphRenderMode.COLOR);

Scripts/Editor/TMP_PackageUtilities.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using UnityEngine;
1+
using UnityEngine;
22
using UnityEngine.SceneManagement;
33
using UnityEditor;
44
using System;
@@ -10,6 +10,11 @@
1010
using System.Threading;
1111
using TMPro.EditorUtilities;
1212

13+
#if UNITY_2023_3_OR_NEWER
14+
using PhysicsMaterialAsset = UnityEngine.PhysicsMaterial;
15+
#else
16+
using PhysicsMaterialAsset = UnityEngine.PhysicMaterial;
17+
#endif
1318

1419
namespace TMPro
1520
{
@@ -618,7 +623,7 @@ static void ShowConverterWindow()
618623
typeof(LightingDataAsset),
619624
typeof(Mesh),
620625
typeof(MonoScript),
621-
typeof(PhysicMaterial),
626+
typeof(PhysicsMaterialAsset),
622627
typeof(PhysicsMaterial2D),
623628
typeof(RenderTexture),
624629
typeof(Shader),

Scripts/Runtime/TMP_FontAsset.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,7 @@ void SetupNewAtlasTexture()
28842884
#if UNITY_EDITOR
28852885
// Add new texture as sub asset to font asset
28862886
Texture2D tex = m_AtlasTextures[m_AtlasTextureIndex];
2887-
tex.name = m_AtlasTextures[0].name + " " + m_AtlasTextureIndex;
2887+
tex.name = atlasTexture.name + " " + m_AtlasTextureIndex;
28882888

28892889
OnFontAssetTextureChanged?.Invoke(tex, this);
28902890
#endif

Scripts/Runtime/TMP_InputField.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ public bool shouldHideSoftKeyboard
452452
case RuntimePlatform.Android:
453453
case RuntimePlatform.IPhonePlayer:
454454
case RuntimePlatform.tvOS:
455+
#if UNITY_2022_3_OR_NEWER
456+
case RuntimePlatform.VisionOS:
457+
#endif
455458
case RuntimePlatform.WSAPlayerX86:
456459
case RuntimePlatform.WSAPlayerX64:
457460
case RuntimePlatform.WSAPlayerARM:
@@ -482,6 +485,9 @@ public bool shouldHideSoftKeyboard
482485
case RuntimePlatform.Android:
483486
case RuntimePlatform.IPhonePlayer:
484487
case RuntimePlatform.tvOS:
488+
#if UNITY_2022_3_OR_NEWER
489+
case RuntimePlatform.VisionOS:
490+
#endif
485491
case RuntimePlatform.WSAPlayerX86:
486492
case RuntimePlatform.WSAPlayerX64:
487493
case RuntimePlatform.WSAPlayerARM:
@@ -522,6 +528,9 @@ private bool isKeyboardUsingEvents()
522528
return InPlaceEditing() && m_HideSoftKeyboard;
523529
case RuntimePlatform.IPhonePlayer:
524530
case RuntimePlatform.tvOS:
531+
#if UNITY_2022_3_OR_NEWER
532+
case RuntimePlatform.VisionOS:
533+
#endif
525534
return m_HideSoftKeyboard;
526535
#if UNITY_2020_2_OR_NEWER
527536
case RuntimePlatform.PS4:
@@ -1768,14 +1777,19 @@ protected virtual void LateUpdate()
17681777
for (int i = 0; i < val.Length; ++i)
17691778
{
17701779
char c = val[i];
1780+
bool hasValidateUpdatedText = false;
17711781

17721782
if (c == '\r' || c == 3)
17731783
c = '\n';
17741784

17751785
if (onValidateInput != null)
17761786
c = onValidateInput(m_Text, m_Text.Length, c);
17771787
else if (characterValidation != CharacterValidation.None)
1788+
{
1789+
string textBeforeValidate = m_Text;
17781790
c = Validate(m_Text, m_Text.Length, c);
1791+
hasValidateUpdatedText = textBeforeValidate != m_Text;
1792+
}
17791793

17801794
if (lineType == LineType.MultiLineSubmit && c == '\n')
17811795
{
@@ -1787,7 +1801,8 @@ protected virtual void LateUpdate()
17871801
}
17881802

17891803
// In the case of a Custom Validator, the user is expected to modify the m_Text where as such we do not append c.
1790-
if (c != 0 && characterValidation != CharacterValidation.CustomValidator)
1804+
// However we will append c if the user did not modify the m_Text (UUM-42147)
1805+
if (c != 0 && (characterValidation != CharacterValidation.CustomValidator || !hasValidateUpdatedText))
17911806
m_Text += c;
17921807
}
17931808

@@ -2236,7 +2251,7 @@ protected EditState KeyPressed(Event evt)
22362251
{
22372252
TMP_TextInfo textInfo = m_TextComponent.textInfo;
22382253

2239-
if (textInfo != null && textInfo.lineCount >= m_LineLimit)
2254+
if (m_LineLimit > 0 && textInfo != null && textInfo.lineCount >= m_LineLimit)
22402255
{
22412256
m_ReleaseSelection = true;
22422257
return EditState.Finish;
@@ -4445,7 +4460,7 @@ public virtual void OnSubmit(BaseEventData eventData)
44454460

44464461
SendOnSubmit();
44474462
DeactivateInputField();
4448-
eventData.Use();
4463+
eventData?.Use();
44494464
}
44504465

44514466
public virtual void OnCancel(BaseEventData eventData)

Scripts/Runtime/TMP_RichTextTagsCommon.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ internal enum MarkupTag
126126
BLACK = 81074727,
127127
WHITE = 105680263,
128128
PURPLE = -1250222130,
129+
GREY = 2638345,
130+
LIGHTBLUE= 341063360,
129131

130132
// Unicode Characters
131133
BR = 2256, // <br> Line Feed (LF) \u000A

Scripts/Runtime/TMP_Text.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,10 +4077,10 @@ protected virtual Vector2 CalculatePreferredValues(ref float fontSize, Vector2 m
40774077
if (m_textElementType == TMP_TextElementType.Sprite)
40784078
{
40794079
// If a sprite is used as a fallback then get a reference to it and set the color to white.
4080-
m_currentSpriteAsset = m_textInfo.characterInfo[m_characterCount].textElement.textAsset as TMP_SpriteAsset;
4081-
m_spriteIndex = (int)m_textInfo.characterInfo[m_characterCount].textElement.glyphIndex;
4080+
TMP_SpriteCharacter sprite = (TMP_SpriteCharacter)m_textInfo.characterInfo[m_characterCount].textElement;
4081+
m_currentSpriteAsset = sprite.textAsset as TMP_SpriteAsset;
4082+
m_spriteIndex = (int)sprite.glyphIndex;
40824083

4083-
TMP_SpriteCharacter sprite = m_currentSpriteAsset.spriteCharacterTable[m_spriteIndex];
40844084
if (sprite == null) continue;
40854085

40864086
// Sprites are assigned in the E000 Private Area + sprite Index
@@ -7669,15 +7669,15 @@ internal bool ValidateHtmlTag(TextProcessingElement[] chars, int startIndex, out
76697669
m_htmlColor = Color.red;
76707670
m_colorStack.Add(m_htmlColor);
76717671
return true;
7672-
case -992792864: // <color=lightblue>
7672+
case (int)MarkupTag.LIGHTBLUE: // <color=lightblue>
76737673
m_htmlColor = new Color32(173, 216, 230, 255);
76747674
m_colorStack.Add(m_htmlColor);
76757675
return true;
76767676
case (int)MarkupTag.BLUE: // <color=blue>
76777677
m_htmlColor = Color.blue;
76787678
m_colorStack.Add(m_htmlColor);
76797679
return true;
7680-
case 3680713: // <color=grey>
7680+
case (int)MarkupTag.GREY: // <color=grey>
76817681
m_htmlColor = new Color32(128, 128, 128, 255);
76827682
m_colorStack.Add(m_htmlColor);
76837683
return true;

Scripts/Runtime/TextMeshPro.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4905,7 +4905,7 @@ protected virtual void GenerateTextMesh()
49054905
#endregion
49064906

49074907
// Set vertex count for Underline geometry
4908-
//m_textInfo.meshInfo[m_Underline.materialIndex].vertexCount = last_vert_index;
4908+
m_textInfo.meshInfo[m_Underline.materialIndex].vertexCount = last_vert_index;
49094909

49104910
// METRICS ABOUT THE TEXT OBJECT
49114911
m_textInfo.characterCount = m_characterCount;

Scripts/Runtime/TextMeshProUGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5271,7 +5271,7 @@ protected virtual void GenerateTextMesh()
52715271
#endregion
52725272

52735273
// Set vertex count for Underline geometry
5274-
//m_textInfo.meshInfo[m_Underline.materialIndex].vertexCount = last_vert_index;
5274+
m_textInfo.meshInfo[m_Underline.materialIndex].vertexCount = last_vert_index;
52755275

52765276
// METRICS ABOUT THE TEXT OBJECT
52775277
m_textInfo.characterCount = m_characterCount;

Tests/Editor/TMP_EditorTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,27 @@ public void MarkupTag_Indent(string sourceText, float origin1, float advance1, f
363363
Assert.AreEqual(advance3, m_TextComponent.textInfo.characterInfo[2].xAdvance);
364364
}
365365

366+
#if TMP_TEST_RESOURCES
367+
const string k_SpriteAssetPath = "Assets/TextMesh Pro/Resources/Sprite Assets/MixedIndexTest.asset";
368+
[Test]
369+
public void SpriteAssetIndexAreValidAfterReordering()
370+
{
371+
var spriteAsset = AssetDatabase.LoadAssetAtPath<TMP_SpriteAsset>(k_SpriteAssetPath);
372+
if (spriteAsset == null)
373+
{
374+
Debug.LogError("Failed to load Sprite Asset at path: " + k_SpriteAssetPath);
375+
return;
376+
}
377+
378+
string text = $"<sprite name=\"cta_obsidianjade\">";
379+
m_TextComponent.spriteAsset = spriteAsset;
380+
m_TextComponent.text = text;
381+
m_TextComponent.ForceMeshUpdate();
382+
383+
Assert.AreEqual(203, m_TextComponent.textInfo.characterInfo[0].textElement.glyphIndex, $"Mismatch between sprite index. Expected 203 but was {m_TextComponent.textInfo.characterInfo[0].textElement.glyphIndex}");
384+
}
385+
#endif
386+
366387

367388
// Add tests that check position of individual characters in a complex block of text.
368389
// These test also use the data contained inside the TMP_TextInfo class.

Tests/Runtime/TMP_RuntimeTests.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,16 @@ public static IEnumerable<object[]> TestCases_MultiLineNewline_OnLastLine_WhenPr
194194
yield return new object[] { 6, 6 };
195195
}
196196

197-
[Test, TestCaseSource("TestCases_MultiLineNewline_OnLastLine_WhenPressedEnter_Caret_ShouldNotGoto_NextLine")]
198-
public void MultiLineNewline_OnLastLine_WhenPressedEnter_Caret_ShouldNotGoto_NextLine(int lineLimit, int expectedLineCount)
197+
[Test, TestCaseSource(nameof(TestCases_MultiLineNewline_OnLastLine_WhenPressedEnter_Caret_ShouldNotGoto_NextLine))]
198+
public void MultiLineNewline_OnLastLine_WhenPressedEnter_Caret_ShouldNotGoto_NextLine(int lineLimit,
199+
int expectedLineCount)
200+
{
201+
MultiLineNewline_LineLimit_ExpectedLineCount_Logic(lineLimit, lineLimit, 3);
202+
Assert.AreEqual(m_TextComponent.textInfo.lineCount, expectedLineCount);
203+
}
204+
205+
private void MultiLineNewline_LineLimit_ExpectedLineCount_Logic(int lineLimitValue, int lineLimitApplied,
206+
int extraKeyDownEventCount)
199207
{
200208
GameObject cameraObject = new GameObject("Camera Object", typeof(Camera));
201209
GameObject canvasObject = new GameObject("Canvas Object", typeof(Canvas), typeof(GraphicRaycaster));
@@ -207,20 +215,20 @@ public void MultiLineNewline_OnLastLine_WhenPressedEnter_Caret_ShouldNotGoto_Nex
207215
m_InputField.targetGraphic = inputObject.GetComponent<Image>();
208216
m_InputField.textComponent = m_TextComponent;
209217
m_InputField.lineType = TMP_InputField.LineType.MultiLineNewline;
210-
m_InputField.lineLimit = lineLimit;
218+
m_InputField.lineLimit = lineLimitValue;
211219

212220
GameObject eventGameObject = new GameObject("Event Object", typeof(EventSystem), typeof(StandaloneInputModule));
213221
Event enterKeyDownEvent = new Event { type = EventType.KeyDown, keyCode = KeyCode.KeypadEnter, modifiers = EventModifiers.None, character = '\n' };
214222

215223
m_InputField.text = "POTUS";
216224
EventSystem.current.SetSelectedGameObject(inputObject);
217225
m_InputField.ActivateInputField();
218-
int count = 0;
219-
while (count < lineLimit + 3)
226+
int count = lineLimitApplied + extraKeyDownEventCount;
227+
while (count > 0)
220228
{
221229
m_InputField.ProcessEvent(enterKeyDownEvent);
222230
m_InputField.ForceLabelUpdate();
223-
count++;
231+
count--;
224232
}
225233

226234
m_InputField.textComponent.ForceMeshUpdate();
@@ -231,8 +239,21 @@ public void MultiLineNewline_OnLastLine_WhenPressedEnter_Caret_ShouldNotGoto_Nex
231239
GameObject.Destroy(inputObject);
232240
GameObject.Destroy(canvasObject);
233241
GameObject.Destroy(cameraObject);
242+
}
234243

235-
Assert.AreEqual(m_TextComponent.textInfo.lineCount, expectedLineCount);
244+
public static IEnumerable<object[]> TestCases_MultiLineNewLine_NegativeOrZeroLineLimit_AddsNewLine()
245+
{
246+
yield return new object[] { 0, 0, 1 };
247+
yield return new object[] { 0, 0, 4 };
248+
yield return new object[] { -1, 0, 2 };
249+
}
250+
251+
[Test, TestCaseSource(nameof(TestCases_MultiLineNewLine_NegativeOrZeroLineLimit_AddsNewLine))]
252+
public void MultiLineNewLine_NegativeOrZeroLineLimit_AddsNewLine(int lineLimitValue, int lineLimitApplied,
253+
int extraKeyDownEventCount)
254+
{
255+
MultiLineNewline_LineLimit_ExpectedLineCount_Logic(lineLimitValue, lineLimitApplied, extraKeyDownEventCount);
256+
Assert.AreEqual(m_TextComponent.textInfo.lineCount, extraKeyDownEventCount + 1);
236257
}
237258

238259
//[OneTimeTearDown]

0 commit comments

Comments
 (0)