Skip to content

Commit 8093d71

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@2.1.5
## [2.1.5] - 2021-04-09
1 parent a2ecd1d commit 8093d71

14 files changed

+160
-167
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
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+
## [2.1.5] - 2021-04-09
5+
## [1.5.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+
- Fixed m_AlphaTweenRunner not initialized in TMP_Dropdown when Reload Domain is disabled in the Editor Enter Play Mode Settings. See [forum post](https://forum.unity.com/threads/m_alphatweenrunner-not-initialized-in-tmp_dropdown.1071887/) for details.
16+
- Added support for PS4 and PS5 to TMP Input Field.
17+
418
## [2.1.4] - 2021-02-19
519
## [1.5.4]
620
## [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

Scripts/Runtime/TMP_Dropdown.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,10 @@ protected TMP_Dropdown() { }
438438

439439
protected override void Awake()
440440
{
441-
//#if UNITY_EDITOR
442-
// if (!Application.isPlaying)
443-
// return;
444-
//#endif
445-
446-
m_AlphaTweenRunner = new TweenRunner<FloatTween>();
447-
m_AlphaTweenRunner.Init(this);
441+
#if UNITY_EDITOR
442+
if (!Application.isPlaying)
443+
return;
444+
#endif
448445

449446
if (m_CaptionImage)
450447
m_CaptionImage.enabled = (m_CaptionImage.sprite != null);
@@ -455,6 +452,8 @@ protected override void Awake()
455452

456453
protected override void Start()
457454
{
455+
m_AlphaTweenRunner = new TweenRunner<FloatTween>();
456+
m_AlphaTweenRunner.Init(this);
458457
base.Start();
459458

460459
RefreshShownValue();

Scripts/Runtime/TMP_FontAsset.cs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -721,47 +721,49 @@ internal void AddSynthesizedCharactersAndFaceMetrics()
721721
{
722722
k_AddSynthesizedCharactersMarker.Begin();
723723

724+
bool isFontFaceLoaded = false;
725+
724726
if (m_AtlasPopulationMode == AtlasPopulationMode.Dynamic)
725-
FontEngine.LoadFontFace(sourceFontFile, m_FaceInfo.pointSize);
727+
isFontFaceLoaded = FontEngine.LoadFontFace(sourceFontFile, m_FaceInfo.pointSize) == FontEngineError.Success;
726728

727729
// Only characters not present in the source font file will be synthesized.
728730

729731
// Non visible and control characters with no metrics
730732
// Add End of Text \u0003
731-
AddSynthesizedCharacter(0x03, true);
733+
AddSynthesizedCharacter(0x03, isFontFaceLoaded, true);
732734

733735
// Add Tab \u0009
734-
AddSynthesizedCharacter(0x09, true);
736+
AddSynthesizedCharacter(0x09, isFontFaceLoaded, true);
735737

736738
// Add Line Feed (LF) \u000A
737-
AddSynthesizedCharacter(0x0A);
739+
AddSynthesizedCharacter(0x0A, isFontFaceLoaded);
738740

739741
// Add Vertical Tab (VT) \u000B
740-
AddSynthesizedCharacter(0x0B);
742+
AddSynthesizedCharacter(0x0B, isFontFaceLoaded);
741743

742744
// Add Carriage Return (CR) \u000D
743-
AddSynthesizedCharacter(0x0D);
745+
AddSynthesizedCharacter(0x0D, isFontFaceLoaded);
744746

745747
// Add Arabic Letter Mark \u061C
746-
AddSynthesizedCharacter(0x061C);
748+
AddSynthesizedCharacter(0x061C, isFontFaceLoaded);
747749

748750
// Add Zero Width Space <ZWSP> \u2000B
749-
AddSynthesizedCharacter(0x200B);
751+
AddSynthesizedCharacter(0x200B, isFontFaceLoaded);
750752

751753
// Add Left-To-Right Mark \u200E
752-
AddSynthesizedCharacter(0x200E);
754+
AddSynthesizedCharacter(0x200E, isFontFaceLoaded);
753755

754756
// Add Right-To-Left Mark \u200F
755-
AddSynthesizedCharacter(0x200F);
757+
AddSynthesizedCharacter(0x200F, isFontFaceLoaded);
756758

757759
// Add Line Separator \u2028
758-
AddSynthesizedCharacter(0x2028);
760+
AddSynthesizedCharacter(0x2028, isFontFaceLoaded);
759761

760762
// Add Paragraph Separator \u2029
761-
AddSynthesizedCharacter(0x2029);
763+
AddSynthesizedCharacter(0x2029, isFontFaceLoaded);
762764

763765
// Add Word Joiner <WJ> / Zero Width Non-Breaking Space \u2060
764-
AddSynthesizedCharacter(0x2060);
766+
AddSynthesizedCharacter(0x2060, isFontFaceLoaded);
765767

766768
// Set Cap Line using the capital letter 'X'
767769
if (m_FaceInfo.capLine == 0 && m_CharacterLookupDictionary.ContainsKey('X'))
@@ -780,15 +782,15 @@ internal void AddSynthesizedCharactersAndFaceMetrics()
780782
k_AddSynthesizedCharactersMarker.End();
781783
}
782784

783-
void AddSynthesizedCharacter(uint unicode, bool addImmediately = false)
785+
void AddSynthesizedCharacter(uint unicode, bool isFontFaceLoaded, bool addImmediately = false)
784786
{
785787
// Check if unicode is already present in the font asset
786788
if (m_CharacterLookupDictionary.ContainsKey(unicode))
787789
return;
788790

789791
Glyph glyph;
790792

791-
if (m_AtlasPopulationMode == AtlasPopulationMode.Dynamic)
793+
if (isFontFaceLoaded)
792794
{
793795
// Check if unicode is present in font file
794796
if (FontEngine.GetGlyphIndex(unicode) != 0)
@@ -2057,18 +2059,18 @@ internal bool TryAddCharacterInternal(uint unicode, out TMP_Character character)
20572059
// }
20582060
//}
20592061

2060-
// Resize the Atlas Texture to the appropriate size
2061-
if (m_AtlasTextures[m_AtlasTextureIndex].width == 0 || m_AtlasTextures[m_AtlasTextureIndex].height == 0)
2062+
// Make sure atlas texture is readable.
2063+
if (m_AtlasTextures[m_AtlasTextureIndex].isReadable == false)
20622064
{
2063-
// TODO: Need texture to be readable.
2064-
if (m_AtlasTextures[m_AtlasTextureIndex].isReadable == false)
2065-
{
2066-
Debug.LogWarning("Unable to add the requested character to font asset [" + this.name + "]'s atlas texture. Please make the texture [" + m_AtlasTextures[m_AtlasTextureIndex].name + "] readable.", m_AtlasTextures[m_AtlasTextureIndex]);
2065+
Debug.LogWarning("Unable to add the requested character to font asset [" + this.name + "]'s atlas texture. Please make the texture [" + m_AtlasTextures[m_AtlasTextureIndex].name + "] readable.", m_AtlasTextures[m_AtlasTextureIndex]);
20672066

2068-
k_TryAddCharacterMarker.End();
2069-
return false;
2070-
}
2067+
k_TryAddCharacterMarker.End();
2068+
return false;
2069+
}
20712070

2071+
// Resize the Atlas Texture to the appropriate size
2072+
if (m_AtlasTextures[m_AtlasTextureIndex].width == 0 || m_AtlasTextures[m_AtlasTextureIndex].height == 0)
2073+
{
20722074
m_AtlasTextures[m_AtlasTextureIndex].Resize(m_AtlasWidth, m_AtlasHeight);
20732075
FontEngine.ResetAtlasTexture(m_AtlasTextures[m_AtlasTextureIndex]);
20742076
}

0 commit comments

Comments
 (0)