Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [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
  • Loading branch information
Unity Technologies committed Apr 2, 2021
1 parent a7bffff commit 8da7026
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 269 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog
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

## [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.5.4] - 2021-02-19
## [2.1.4]
## [3.0.4]
Expand Down
6 changes: 4 additions & 2 deletions Scripts/Editor/TMP_EditorPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ private void DrawSortingLayer()

EditorGUI.BeginProperty(rect, k_SortingLayerLabel, sortingLayerIDProp);
EditorGUI.BeginChangeCheck();
int newLayerIndex = EditorGUI.Popup(rect, k_SortingLayerLabel, sortingLayerProp.intValue, k_SortingLayerNames);

int currentLayerIndex = SortingLayerHelper.GetSortingLayerIndexFromSortingLayerID(sortingLayerIDProp.intValue);
int newLayerIndex = EditorGUI.Popup(rect, k_SortingLayerLabel, currentLayerIndex, k_SortingLayerNames);

if (EditorGUI.EndChangeCheck())
{
sortingLayerProp.intValue = newLayerIndex;
sortingLayerIDProp.intValue = SortingLayer.NameToID(k_SortingLayerNames[newLayerIndex]);
sortingLayerProp.intValue = SortingLayer.GetLayerValueFromName(k_SortingLayerNames[newLayerIndex]);
m_HavePropertiesChanged = true;

// Sync Sorting Layer ID change on potential sub text object.
Expand Down
11 changes: 6 additions & 5 deletions Scripts/Editor/TMP_PackageUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using TMPro.EditorUtilities;

Expand Down Expand Up @@ -413,7 +414,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
{
if (line.Contains(k_FontSizeProperty))
{
fontSize = float.Parse(line.Split(':')[1]);
fontSize = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
readingFlag = 3;
continue;
}
Expand All @@ -425,7 +426,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
// Read character spacing
if (line.Contains(k_CharacterSpacingProperty))
{
characterSpacingValue = float.Parse(line.Split(':')[1]);
characterSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
if (characterSpacingValue != 0)
{
// Convert character spacing value.
Expand All @@ -441,7 +442,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
if (line.Contains(k_WordSpacingProperty))
{
// Get the character spacing value
wordSpacingValue = float.Parse(line.Split(':')[1]);
wordSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
if (wordSpacingValue != 0)
{
// Convert character spacing value.
Expand All @@ -457,7 +458,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
if (line.Contains(k_LineSpacingProperty))
{
// Get the value of line spacing value
lineSpacingValue = float.Parse(line.Split(':')[1]);
lineSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
if (lineSpacingValue != 0)
{
// Convert line spacing value.
Expand All @@ -473,7 +474,7 @@ static void ScanProjectFile(AssetFileRecord fileRecord)
if (line.Contains(k_ParagraphSpacingProperty))
{
// Get the value of line spacing value
paragraphSpacingValue = float.Parse(line.Split(':')[1]);
paragraphSpacingValue = float.Parse(line.Split(':')[1], NumberStyles.Float, CultureInfo.InvariantCulture);
if (paragraphSpacingValue != 0)
{
// Convert line spacing value.
Expand Down
26 changes: 26 additions & 0 deletions Scripts/Editor/TMPro_SortingLayerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,31 @@ static string[] GetSortingLayerNames()

return layerNames;
}

internal static int GetSortingLayerIndexFromValue(int value)
{
int layerCount = SortingLayer.layers.Length;

for (int i = 0; i < layerCount; i++)
{
if (value == SortingLayer.layers[i].value)
return i;
}

return -1;
}

internal static int GetSortingLayerIndexFromSortingLayerID(int id)
{
int layerCount = SortingLayer.layers.Length;

for (int i = 0; i < layerCount; i++)
{
if (id == SortingLayer.layers[i].id)
return i;
}

return -1;
}
}
}
69 changes: 12 additions & 57 deletions Scripts/Editor/TMPro_TexturePostProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using UnityEngine;
using UnityEditor;
using System.Collections;


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

if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(TMP_FontAsset))
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(asset);

if (assetType == typeof(TMP_FontAsset))
{
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath(asset, typeof(TMP_FontAsset)) as TMP_FontAsset;

if (fontAsset != null)
// Only refresh font asset definition if font asset was previously initialized.
if (fontAsset != null && fontAsset.m_CharacterLookupDictionary != null)
TMP_EditorResourceManager.RegisterFontAssetForDefinitionRefresh(fontAsset);
}

if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(Texture2D))
if (assetType == typeof(Texture2D))
{
Texture2D tex = AssetDatabase.LoadAssetAtPath(asset, typeof(Texture2D)) as Texture2D;

if (tex != null)
TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
if (tex == null)
continue;

TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
Resources.UnloadAsset(tex);
}
}
}
}

//public class TMPro_PackageImportPostProcessor : AssetPostprocessor
//{
// static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
// {
// for (int i = 0; i < importedAssets.Length; i++)
// {
// if (importedAssets[i].Contains("TextMesh Pro/Resources/TMP Settings.asset"))
// {
// Debug.Log("New TMP Settings file was just imported.");

// // TMP Settings file was just re-imported.
// // Check if project already contains
// }


// if (importedAssets[i].Contains("com.unity.TextMeshPro/Examples"))
// {
// //Debug.Log("New TMP Examples folder was just imported.");
// }

// //Debug.Log("[" + importedAssets[i] + "] was just imported.");
// }



// //for (int i = 0; i < deletedAssets.Length; i++)
// //{
// // if (deletedAssets[i] == "Assets/TextMesh Pro")
// // {
// // //Debug.Log("Asset [" + deletedAssets[i] + "] has been deleted.");
// // string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);

// // //Check for and inject TMP_PRESENT
// // if (currentBuildSettings.Contains("TMP_PRESENT;"))
// // {
// // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT;", "");

// // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
// // }
// // else if (currentBuildSettings.Contains("TMP_PRESENT"))
// // {
// // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT", "");

// // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
// // }
// // }
// //}
// }
//}
}
2 changes: 1 addition & 1 deletion Scripts/Runtime/TMP_DefaultControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static GameObject CreateInputField(Resources resources)

// Use UI.Mask for Unity 5.0 - 5.1 and 2D RectMask for Unity 5.2 and up
RectMask2D rectMask = textArea.AddComponent<RectMask2D>();
#if UNITY_2019_4_OR_NEWER
#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
rectMask.padding = new Vector4(-8, -5, -8, -5);
#endif

Expand Down
Loading

0 comments on commit 8da7026

Please sign in to comment.