Skip to content

Commit 8da7026

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@1.5.5
## [1.5.5] - 2021-04-02 ## [2.1.5] ## [3.0.5] ### Changes - Added compiler conditional to address error related to missing RectMask2D padding property which was added in Unity 2019.4.12f1. See [forum post](https://forum.unity.com/threads/update-textmesh-pro-to-latest-in-2019-4.945332/#post-6906851) for details. - Fixed GetPreferredValues(string text) and GetPreferredValues(string text, float width, float height) incorrectly changing the text. See [forum post](https://forum.unity.com/threads/preferred-width-height-sometimes-0.980022/#post-6991058) for details. - Fixed potential crash when FontEngine.GetGlyphIndex is called on a font asset that was previously unloaded or deleted. See [forum post](https://forum.unity.com/threads/tmpro-tmp_fontasset-addsynthesizedcharacter-causes-crash-when-calling-fontengine-getglyphindex.1071452/) for details. - Fixed potential crash when trying to add new glyphs to a dynamic font asset whose atlas texture is set to non readable. Case #1319567 - Fixed Format Exception error when using the Project Text Spacing Conversion Tool when the Language Region Format is not English. Case #1320544 - Fixed text rendering issue due to incorrectly SDF scaling when using a CanvasScaler and resizing the game view. - Fixed TextMeshPro component Sorting Layer field in the Inspector's Extra Settings not showing the correct layer. Case #1326985
1 parent a7bffff commit 8da7026

13 files changed

+141
-269
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+
## [1.5.5] - 2021-04-02
5+
## [2.1.5]
6+
## [3.0.5]
7+
### Changes
8+
- Added compiler conditional to address error related to missing RectMask2D padding property which was added in Unity 2019.4.12f1. See [forum post](https://forum.unity.com/threads/update-textmesh-pro-to-latest-in-2019-4.945332/#post-6906851) for details.
9+
- Fixed GetPreferredValues(string text) and GetPreferredValues(string text, float width, float height) incorrectly changing the text. See [forum post](https://forum.unity.com/threads/preferred-width-height-sometimes-0.980022/#post-6991058) for details.
10+
- Fixed potential crash when FontEngine.GetGlyphIndex is called on a font asset that was previously unloaded or deleted. See [forum post](https://forum.unity.com/threads/tmpro-tmp_fontasset-addsynthesizedcharacter-causes-crash-when-calling-fontengine-getglyphindex.1071452/) for details.
11+
- Fixed potential crash when trying to add new glyphs to a dynamic font asset whose atlas texture is set to non readable. Case #1319567
12+
- Fixed Format Exception error when using the Project Text Spacing Conversion Tool when the Language Region Format is not English. Case #1320544
13+
- Fixed text rendering issue due to incorrectly SDF scaling when using a CanvasScaler and resizing the game view.
14+
- Fixed TextMeshPro component Sorting Layer field in the Inspector's Extra Settings not showing the correct layer. Case #1326985
15+
416
## [1.5.4] - 2021-02-19
517
## [2.1.4]
618
## [3.0.4]

Scripts/Editor/TMP_EditorPanel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ private void DrawSortingLayer()
111111

112112
EditorGUI.BeginProperty(rect, k_SortingLayerLabel, sortingLayerIDProp);
113113
EditorGUI.BeginChangeCheck();
114-
int newLayerIndex = EditorGUI.Popup(rect, k_SortingLayerLabel, sortingLayerProp.intValue, k_SortingLayerNames);
114+
115+
int currentLayerIndex = SortingLayerHelper.GetSortingLayerIndexFromSortingLayerID(sortingLayerIDProp.intValue);
116+
int newLayerIndex = EditorGUI.Popup(rect, k_SortingLayerLabel, currentLayerIndex, k_SortingLayerNames);
115117

116118
if (EditorGUI.EndChangeCheck())
117119
{
118-
sortingLayerProp.intValue = newLayerIndex;
119120
sortingLayerIDProp.intValue = SortingLayer.NameToID(k_SortingLayerNames[newLayerIndex]);
121+
sortingLayerProp.intValue = SortingLayer.GetLayerValueFromName(k_SortingLayerNames[newLayerIndex]);
120122
m_HavePropertiesChanged = true;
121123

122124
// Sync Sorting Layer ID change on potential sub text object.

Scripts/Editor/TMP_PackageUtilities.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Collections;
88
using System.Collections.Generic;
9+
using System.Globalization;
910
using System.Threading;
1011
using TMPro.EditorUtilities;
1112

@@ -413,7 +414,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
413414
{
414415
if (line.Contains(k_FontSizeProperty))
415416
{
416-
fontSize = float.Parse(line.Split(':')[1]);
417+
fontSize = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
417418
readingFlag = 3;
418419
continue;
419420
}
@@ -425,7 +426,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
425426
// Read character spacing
426427
if (line.Contains(k_CharacterSpacingProperty))
427428
{
428-
characterSpacingValue = float.Parse(line.Split(':')[1]);
429+
characterSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
429430
if (characterSpacingValue != 0)
430431
{
431432
// Convert character spacing value.
@@ -441,7 +442,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
441442
if (line.Contains(k_WordSpacingProperty))
442443
{
443444
// Get the character spacing value
444-
wordSpacingValue = float.Parse(line.Split(':')[1]);
445+
wordSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
445446
if (wordSpacingValue != 0)
446447
{
447448
// Convert character spacing value.
@@ -457,7 +458,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
457458
if (line.Contains(k_LineSpacingProperty))
458459
{
459460
// Get the value of line spacing value
460-
lineSpacingValue = float.Parse(line.Split(':')[1]);
461+
lineSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
461462
if (lineSpacingValue != 0)
462463
{
463464
// Convert line spacing value.
@@ -473,7 +474,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
473474
if (line.Contains(k_ParagraphSpacingProperty))
474475
{
475476
// Get the value of line spacing value
476-
paragraphSpacingValue = float.Parse(line.Split(':')[1]);
477+
paragraphSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
477478
if (paragraphSpacingValue != 0)
478479
{
479480
// Convert line spacing value.

Scripts/Editor/TMPro_SortingLayerHelper.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,31 @@ static string[] GetSortingLayerNames()
2828

2929
return layerNames;
3030
}
31+
32+
internal static int GetSortingLayerIndexFromValue(int value)
33+
{
34+
int layerCount = SortingLayer.layers.Length;
35+
36+
for (int i = 0; i < layerCount; i++)
37+
{
38+
if (value == SortingLayer.layers[i].value)
39+
return i;
40+
}
41+
42+
return -1;
43+
}
44+
45+
internal static int GetSortingLayerIndexFromSortingLayerID(int id)
46+
{
47+
int layerCount = SortingLayer.layers.Length;
48+
49+
for (int i = 0; i < layerCount; i++)
50+
{
51+
if (id == SortingLayer.layers[i].id)
52+
return i;
53+
}
54+
55+
return -1;
56+
}
3157
}
3258
}
Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using UnityEngine;
33
using UnityEditor;
4-
using System.Collections;
54

65

76
namespace TMPro.EditorUtilities
@@ -10,7 +9,7 @@ namespace TMPro.EditorUtilities
109
/// Asset post processor used to handle text assets changes.
1110
/// This includes tracking of changes to textures used by sprite assets as well as font assets potentially getting updated outside of the Unity editor.
1211
/// </summary>
13-
public class TMPro_TexturePostProcessor : AssetPostprocessor
12+
internal class TMPro_TexturePostProcessor : AssetPostprocessor
1413
{
1514
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
1615
{
@@ -20,72 +19,28 @@ private static void OnPostprocessAllAssets(string[] importedAssets, string[] del
2019
if (asset.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase) == false)
2120
continue;
2221

23-
if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(TMP_FontAsset))
22+
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(asset);
23+
24+
if (assetType == typeof(TMP_FontAsset))
2425
{
2526
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath(asset, typeof(TMP_FontAsset)) as TMP_FontAsset;
2627

27-
if (fontAsset != null)
28+
// Only refresh font asset definition if font asset was previously initialized.
29+
if (fontAsset != null && fontAsset.m_CharacterLookupDictionary != null)
2830
TMP_EditorResourceManager.RegisterFontAssetForDefinitionRefresh(fontAsset);
2931
}
3032

31-
if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(Texture2D))
33+
if (assetType == typeof(Texture2D))
3234
{
3335
Texture2D tex = AssetDatabase.LoadAssetAtPath(asset, typeof(Texture2D)) as Texture2D;
3436

35-
if (tex != null)
36-
TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
37+
if (tex == null)
38+
continue;
39+
40+
TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
41+
Resources.UnloadAsset(tex);
3742
}
3843
}
3944
}
4045
}
41-
42-
//public class TMPro_PackageImportPostProcessor : AssetPostprocessor
43-
//{
44-
// static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
45-
// {
46-
// for (int i = 0; i < importedAssets.Length; i++)
47-
// {
48-
// if (importedAssets[i].Contains("TextMesh Pro/Resources/TMP Settings.asset"))
49-
// {
50-
// Debug.Log("New TMP Settings file was just imported.");
51-
52-
// // TMP Settings file was just re-imported.
53-
// // Check if project already contains
54-
// }
55-
56-
57-
// if (importedAssets[i].Contains("com.unity.TextMeshPro/Examples"))
58-
// {
59-
// //Debug.Log("New TMP Examples folder was just imported.");
60-
// }
61-
62-
// //Debug.Log("[" + importedAssets[i] + "] was just imported.");
63-
// }
64-
65-
66-
67-
// //for (int i = 0; i < deletedAssets.Length; i++)
68-
// //{
69-
// // if (deletedAssets[i] == "Assets/TextMesh Pro")
70-
// // {
71-
// // //Debug.Log("Asset [" + deletedAssets[i] + "] has been deleted.");
72-
// // string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
73-
74-
// // //Check for and inject TMP_PRESENT
75-
// // if (currentBuildSettings.Contains("TMP_PRESENT;"))
76-
// // {
77-
// // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT;", "");
78-
79-
// // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
80-
// // }
81-
// // else if (currentBuildSettings.Contains("TMP_PRESENT"))
82-
// // {
83-
// // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT", "");
84-
85-
// // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
86-
// // }
87-
// // }
88-
// //}
89-
// }
90-
//}
9146
}

Scripts/Runtime/TMP_DefaultControls.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public static GameObject CreateInputField(Resources resources)
184184

185185
// Use UI.Mask for Unity 5.0 - 5.1 and 2D RectMask for Unity 5.2 and up
186186
RectMask2D rectMask = textArea.AddComponent<RectMask2D>();
187-
#if UNITY_2019_4_OR_NEWER
187+
#if UNITY_2019_4_OR_NEWER && !UNITY_2019_4_1 && !UNITY_2019_4_2 && !UNITY_2019_4_3 && !UNITY_2019_4_4 && !UNITY_2019_4_5 && !UNITY_2019_4_6 && !UNITY_2019_4_7 && !UNITY_2019_4_8 && !UNITY_2019_4_9 && !UNITY_2019_4_10 && !UNITY_2019_4_11
188188
rectMask.padding = new Vector4(-8, -5, -8, -5);
189189
#endif
190190

0 commit comments

Comments
 (0)