Skip to content

Commit 2f2ebb8

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@1.5.1
## [1.5.1] - 2020-07-26 ## [2.1.1] ## [3.0.1] ### Changes - Addressed compiler warning related to the new virtual event OnPreRenderText. - 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. - 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. - Added Editor only font asset post processor to handle font assets being modified outside of the Unity Editor. - 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. - 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.
1 parent ae66a48 commit 2f2ebb8

15 files changed

+148
-145
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+
## [1.5.1] - 2020-07-26
5+
## [2.1.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
## [1.5.0] - 2020-06-30
516
## [2.1.0]
617
## [3.0.0]

Scripts/Editor/TMP_PackageUtilities.cs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -460,57 +460,6 @@ private static bool CheckProjectSerializationAndSourceControlModes()
460460
}
461461

462462

463-
/*
464-
public class TMP_ShaderRemappingTool : EditorWindow
465-
{
466-
// Create Shader Reference Upgrade Tool window
467-
[MenuItem("Window/TextMeshPro/Shader Reference Remapping Tool", false, 2110)]
468-
static void ShowShaderUpgradeWindow()
469-
{
470-
var window = GetWindow<TMP_ShaderRemappingTool>();
471-
window.titleContent = new GUIContent("Shader Upgrade Tool");
472-
window.Focus();
473-
}
474-
475-
private static string k_ProjectMaterialScanReportDefaultText = "<color=#FFFF80><b>Project Scan Results</b></color>\n";
476-
private static string m_ProjectMaterialScanResults = string.Empty;
477-
478-
479-
void OnEnable()
480-
{
481-
// Set Editor Window Size
482-
SetEditorWindowSize();
483-
484-
m_ProjectMaterialScanResults = k_ProjectMaterialScanReportDefaultText;
485-
}
486-
487-
488-
private void OnGUI()
489-
{
490-
491-
}
492-
493-
494-
void OnInspectorUpdate()
495-
{
496-
Repaint();
497-
}
498-
499-
500-
/// <summary>
501-
/// Limits the minimum size of the editor window.
502-
/// </summary>
503-
void SetEditorWindowSize()
504-
{
505-
EditorWindow editorWindow = this;
506-
507-
Vector2 currentWindowSize = editorWindow.minSize;
508-
509-
editorWindow.minSize = new Vector2(Mathf.Max(640, currentWindowSize.x), Mathf.Max(420, currentWindowSize.y));
510-
}
511-
}
512-
*/
513-
514463

515464
public class TMP_PackageUtilities : Editor
516465
{

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ public static TMP_FontAsset CreateFontAsset(string fontFilePath, int samplingPoi
632632
}
633633
*/
634634

635-
636635
void Awake()
637636
{
638637
// Check version number of font asset to see if it needs to be upgraded.
@@ -649,6 +648,8 @@ private void OnValidate()
649648
}
650649
#endif
651650

651+
private static string s_DefaultMaterialSuffix = " Atlas Material";
652+
652653
public void ReadFontAssetDefinition()
653654
{
654655
Profiler.BeginSample("TMP.ReadFontAssetDefinition");
@@ -684,7 +685,7 @@ public void ReadFontAssetDefinition()
684685
hashCode = TMP_TextUtilities.GetSimpleHashCode(this.name);
685686

686687
// Compute Hashcode for the material name
687-
materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name);
688+
materialHashCode = TMP_TextUtilities.GetSimpleHashCode(this.name + s_DefaultMaterialSuffix);
688689

689690
// Add reference to font asset in TMP Resource Manager
690691
//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;
@@ -3821,7 +3822,9 @@ protected char Validate(string text, int pos, char ch)
38213822
{
38223823
if (ch >= '0' && ch <= '9') return ch;
38233824
if (ch == '-' && (pos == 0 || selectionAtStart)) return ch;
3824-
if (ch == '.' && characterValidation == CharacterValidation.Decimal && !text.Contains(".")) return ch;
3825+
3826+
var separator = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
3827+
if (ch == Convert.ToChar(separator) && characterValidation == CharacterValidation.Decimal && !text.Contains(separator)) return ch;
38253828
}
38263829
}
38273830
else if (characterValidation == CharacterValidation.Digit)

0 commit comments

Comments
 (0)