Skip to content

Commit 3854337

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@2.1.1
## [2.1.1] - 2020-07-26
1 parent 40adb02 commit 3854337

15 files changed

+149
-96
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
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.1] - 2020-07-26
5+
## [1.5.1]
6+
## [3.0.1]
7+
### Changes
8+
- Addressed compiler warning related to the new virtual event OnPreRenderText.
9+
- Added one additional layer of missing character search where in the even the missing glyph character \u0000 or space character \u0020 is not available in any font asset or potential fallbacks, the End of Text (ETX) \u0003 will be used instead.
10+
- Input Field Integer or Decimal validation will now take into account the current culture. See [forum post](https://forum.unity.com/threads/currentculture-decimal-separator-in-input-fields.908999/) for details.
11+
- Added Editor only font asset post processor to handle font assets being modified outside of the Unity Editor.
12+
- Fixed potential Array Out of Bounds error that could occur when using </style> without first using a valid <style>. Case #1263787 and See [forum post](https://forum.unity.com/threads/missingreferenceexception-occurs-on-selecting-a-tmp-dropdown-in-the-hierarchy-after-a-play-occurs.728018/#post-6094317) for details.
13+
- Fixed potential issue when using multiple <font> tag in the same text object where these referencing several font assets derived from the same font file. Since their Default Material all have the same name, this was causing an issue in the Material Reference Manager. See [forum post](https://forum.unity.com/threads/argumentexception-on-v2-1-0-unity-2019-4-4f1-identified-bug.934789/) for details. Case #1264596.
14+
415
## [2.1.0] - 2020-06-30
516
## [1.5.0]
617
## [3.0.0]

Scripts/Editor/TMPro_FontAssetCreatorWindow.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ void DrawControls()
936936
m_StopWatch.Stop();
937937
m_GlyphPackingGenerationTime = m_StopWatch.Elapsed.TotalMilliseconds;
938938
m_IsGlyphPackingDone = true;
939-
//Debug.Log("Glyph packing completed in: " + m_GlyphPackingGenerationTime.ToString("0.000 ms."));
940939
m_StopWatch.Reset();
941940

942941
m_FontCharacterTable.Clear();
@@ -1003,7 +1002,6 @@ void DrawControls()
10031002
m_StopWatch.Stop();
10041003
m_GlyphRenderingGenerationTime = m_StopWatch.Elapsed.TotalMilliseconds;
10051004
m_IsGlyphRenderingDone = true;
1006-
//Debug.Log("Font Atlas generation completed in: " + m_GlyphRenderingGenerationTime.ToString("0.000 ms."));
10071005
m_StopWatch.Reset();
10081006
});
10091007
}

Scripts/Editor/TMPro_TexturePostProcessor.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityEngine;
1+
using System;
2+
using UnityEngine;
23
using UnityEditor;
34
using System.Collections;
45

@@ -8,20 +9,35 @@ namespace TMPro.EditorUtilities
89

910
public class TMPro_TexturePostProcessor : AssetPostprocessor
1011
{
11-
1212
void OnPostprocessTexture(Texture2D texture)
1313
{
14-
//var importer = assetImporter as TextureImporter;
15-
1614
Texture2D tex = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)) as Texture2D;
1715

1816
// Send Event Sub Objects
1917
if (tex != null)
2018
TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
2119
}
22-
2320
}
2421

22+
/// <summary>
23+
/// Asset post processor used to handle font assets getting updated outside of the Unity editor.
24+
/// </summary>
25+
class FontAssetPostProcessor : AssetPostprocessor
26+
{
27+
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
28+
{
29+
foreach (var asset in importedAssets)
30+
{
31+
if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(TMP_FontAsset))
32+
{
33+
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath(asset, typeof(TMP_FontAsset)) as TMP_FontAsset;
34+
35+
if (fontAsset != null)
36+
TMP_EditorResourceManager.RegisterFontAssetForDefinitionRefresh(fontAsset);
37+
}
38+
}
39+
}
40+
}
2541

2642
//public class TMPro_PackageImportPostProcessor : AssetPostprocessor
2743
//{
@@ -34,7 +50,7 @@ void OnPostprocessTexture(Texture2D texture)
3450
// Debug.Log("New TMP Settings file was just imported.");
3551

3652
// // TMP Settings file was just re-imported.
37-
// // Check if project already contains
53+
// // Check if project already contains
3854
// }
3955

4056

@@ -45,9 +61,9 @@ void OnPostprocessTexture(Texture2D texture)
4561

4662
// //Debug.Log("[" + importedAssets[i] + "] was just imported.");
4763
// }
48-
49-
50-
64+
65+
66+
5167
// //for (int i = 0; i < deletedAssets.Length; i++)
5268
// //{
5369
// // if (deletedAssets[i] == "Assets/TextMesh Pro")
@@ -72,4 +88,4 @@ void OnPostprocessTexture(Texture2D texture)
7288
// //}
7389
// }
7490
//}
75-
}
91+
}

Scripts/Runtime/TMP_CharacterInfo.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using UnityEngine;
2-
using UnityEngine.TextCore;
1+
using System.Diagnostics;
2+
using UnityEngine;
3+
34

45
namespace TMPro
56
{
@@ -157,6 +158,7 @@ public bool Equals(HighlightState other)
157158
/// <summary>
158159
/// Structure containing information about individual text elements (character or sprites).
159160
/// </summary>
161+
[DebuggerDisplay("Unicode '{character}' ({((uint)character).ToString(\"X\")})")]
160162
public struct TMP_CharacterInfo
161163
{
162164
public char character; // Should be changed to an uint to handle UTF32

Scripts/Runtime/TMP_EditorResourceManager.cs

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public class TMP_EditorResourceManager
1717
private readonly List<Object> m_ObjectReImportQueue = new List<Object>();
1818
private HashSet<int> m_ObjectReImportQueueLookup = new HashSet<int>();
1919

20+
private readonly List<TMP_FontAsset> m_FontAssetDefinitionRefreshQueue = new List<TMP_FontAsset>();
21+
private HashSet<int> m_FontAssetDefinitionRefreshQueueLookup = new HashSet<int>();
22+
2023
/// <summary>
2124
/// Get a singleton instance of the manager.
2225
/// </summary>
@@ -67,8 +70,6 @@ private void InternalRegisterResourceForReimport(Object obj)
6770

6871
m_ObjectReImportQueueLookup.Add(id);
6972
m_ObjectReImportQueue.Add(obj);
70-
71-
return;
7273
}
7374

7475
/// <summary>
@@ -89,8 +90,26 @@ private void InternalRegisterResourceForUpdate(Object obj)
8990

9091
m_ObjectUpdateQueueLookup.Add(id);
9192
m_ObjectUpdateQueue.Add(obj);
93+
}
9294

93-
return;
95+
/// <summary>
96+
///
97+
/// </summary>
98+
/// <param name="fontAsset"></param>
99+
internal static void RegisterFontAssetForDefinitionRefresh(TMP_FontAsset fontAsset)
100+
{
101+
instance.InternalRegisterFontAssetForDefinitionRefresh(fontAsset);
102+
}
103+
104+
private void InternalRegisterFontAssetForDefinitionRefresh(TMP_FontAsset fontAsset)
105+
{
106+
int id = fontAsset.GetInstanceID();
107+
108+
if (m_FontAssetDefinitionRefreshQueueLookup.Contains(id))
109+
return;
110+
111+
m_FontAssetDefinitionRefreshQueueLookup.Add(id);
112+
m_FontAssetDefinitionRefreshQueue.Add(fontAsset);
94113
}
95114

96115

@@ -135,6 +154,24 @@ void DoUpdates()
135154
m_ObjectReImportQueue.Clear();
136155
m_ObjectReImportQueueLookup.Clear();
137156
}
157+
158+
// Handle Font Asset Definition Refresh
159+
for (int i = 0; i < m_FontAssetDefinitionRefreshQueue.Count; i++)
160+
{
161+
TMP_FontAsset fontAsset = m_FontAssetDefinitionRefreshQueue[i];
162+
163+
if (fontAsset != null)
164+
{
165+
fontAsset.ReadFontAssetDefinition();
166+
TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
167+
}
168+
}
169+
170+
if (m_FontAssetDefinitionRefreshQueue.Count > 0)
171+
{
172+
m_FontAssetDefinitionRefreshQueue.Clear();
173+
m_FontAssetDefinitionRefreshQueueLookup.Clear();
174+
}
138175
}
139176

140177
}

Scripts/Runtime/TMP_FontAsset.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ private void OnValidate()
538538
}
539539
#endif
540540

541+
private static string s_DefaultMaterialSuffix = " Atlas Material";
542+
541543
public void ReadFontAssetDefinition()
542544
{
543545
Profiler.BeginSample("TMP.ReadFontAssetDefinition");
@@ -573,7 +575,7 @@ public void ReadFontAssetDefinition()
573575
hashCode = TMP_TextUtilities.GetSimpleHashCode(this.name);
574576

575577
// Compute Hashcode for the material name
576-
materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name);
578+
materialHashCode = TMP_TextUtilities.GetSimpleHashCode(this.name + s_DefaultMaterialSuffix);
577579

578580
// Add reference to font asset in TMP Resource Manager
579581
//TMP_ResourceManager.AddFontAsset(this);

Scripts/Runtime/TMP_FontFeaturesCommon.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace TMPro
99
{
10+
[Flags]
1011
public enum FontFeatureLookupFlags
1112
{
1213
None = 0x0,
@@ -161,7 +162,7 @@ public class TMP_GlyphPairAdjustmentRecord
161162
public TMP_GlyphAdjustmentRecord secondAdjustmentRecord { get { return m_SecondAdjustmentRecord; } set { m_SecondAdjustmentRecord = value; } }
162163

163164
/// <summary>
164-
///
165+
///
165166
/// </summary>
166167
public FontFeatureLookupFlags featureLookupFlags { get { return m_FeatureLookupFlags; } set { m_FeatureLookupFlags = value; } }
167168

@@ -191,7 +192,7 @@ public TMP_GlyphPairAdjustmentRecord(TMP_GlyphAdjustmentRecord firstAdjustmentRe
191192
}
192193

193194
/// <summary>
194-
/// Internal constructor
195+
/// Internal constructor
195196
/// </summary>
196197
/// <param name="firstAdjustmentRecord"></param>
197198
/// <param name="secondAdjustmentRecord"></param>

Scripts/Runtime/TMP_InputField.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections;
55
using System.Collections.Generic;
6+
using System.Threading;
67
using System.Text;
78
using System.Text.RegularExpressions;
89
using UnityEngine;
@@ -3827,7 +3828,9 @@ protected char Validate(string text, int pos, char ch)
38273828
{
38283829
if (ch >= '0' && ch <= '9') return ch;
38293830
if (ch == '-' && (pos == 0 || selectionAtStart)) return ch;
3830-
if (ch == '.' && characterValidation == CharacterValidation.Decimal && !text.Contains(".")) return ch;
3831+
3832+
var separator = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
3833+
if (ch == Convert.ToChar(separator) && characterValidation == CharacterValidation.Decimal && !text.Contains(separator)) return ch;
38313834
}
38323835
}
38333836
else if (characterValidation == CharacterValidation.Digit)

0 commit comments

Comments
 (0)