From 88be79d461b16723b61c7d271a31c98780594d13 Mon Sep 17 00:00:00 2001 From: Unity Technologies <@unity.com> Date: Fri, 22 May 2020 00:00:00 +0200 Subject: [PATCH] com.unity.textmeshpro@2.1.0-preview.13 ## [2.1.0-preview.13] - 2020-05-22 --- CHANGELOG.md | 9 +++ .../Editor/TMPro_FontAssetCreatorWindow.cs | 20 ++++++- Scripts/Runtime/TMP_SubMesh.cs | 57 ++++++++++--------- Scripts/Runtime/TMP_SubMeshUI.cs | 4 ++ Scripts/Runtime/TMPro_Private.cs | 12 ++-- Scripts/Runtime/TMPro_UGUI_Private.cs | 19 ++++--- Scripts/Runtime/TextMeshProUGUI.cs | 2 +- package.json | 6 +- 8 files changed, 84 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f79976d..fa06017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # 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 +## [2.1.0-preview.13] - 2020-05-22 +## [1.5.0-preview.13] +## [3.0.0-preview.13] +### Changes +- Fixed potential issue where the Font Asset Creator could get stuck in the packing phase of the atlas generation process. See [forum post](https://forum.unity.com/threads/font-asset-creator-stuck-at-packing-glyphs-pass-8.811863/) for details. +- Fixed issue potentially affecting text layout as a result of the width of the RectTransform being incorrectly reported. See [forum post](https://forum.unity.com/threads/textmesh-pro-forcemeshupdate-true-not-working-when-object-inactive.524507/#post-5798515) for details. +- Previously created prefabs containing sub text objects will now have their HideFlags updated to HideFlags.DontSave to be consistent with newly created prefabs whose sub text objects are no longer serialized. Case #1247184 +- Fixed culling issue where lossy scale was not considered in the determination of the bounds of the text geometry. + ## [2.1.0-preview.12] - 2020-05-09 ## [1.5.0-preview.12] ## [3.0.0-preview.12] diff --git a/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs b/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs index a3c6c76..14520b1 100644 --- a/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs +++ b/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs @@ -126,6 +126,8 @@ enum FontPackingModes { Fast = 0, Optimum = 4 }; float m_AtlasGenerationProgress; string m_AtlasGenerationProgressLabel = string.Empty; float m_RenderingProgress; + bool m_IsGlyphPackingDone; + bool m_IsGlyphRenderingDone; bool m_IsRenderingDone; bool m_IsProcessing; bool m_IsGenerationDisabled; @@ -281,6 +283,18 @@ public void Update() m_IsRepaintNeeded = true; } + if (m_IsGlyphPackingDone) + { + Debug.Log("Glyph packing completed in: " + m_GlyphPackingGenerationTime.ToString("0.000 ms.")); + m_IsGlyphPackingDone = false; + } + + if (m_IsGlyphRenderingDone) + { + Debug.Log("Font Atlas generation completed in: " + m_GlyphRenderingGenerationTime.ToString("0.000 ms.")); + m_IsGlyphRenderingDone = false; + } + // Update Feedback Window & Create Font Texture once Rendering is done. if (m_IsRenderingDone) { @@ -921,7 +935,8 @@ void DrawControls() //Stop StopWatch m_StopWatch.Stop(); m_GlyphPackingGenerationTime = m_StopWatch.Elapsed.TotalMilliseconds; - Debug.Log("Glyph packing completed in: " + m_GlyphPackingGenerationTime.ToString("0.000 ms.")); + m_IsGlyphPackingDone = true; + //Debug.Log("Glyph packing completed in: " + m_GlyphPackingGenerationTime.ToString("0.000 ms.")); m_StopWatch.Reset(); m_FontCharacterTable.Clear(); @@ -987,7 +1002,8 @@ void DrawControls() // Stop StopWatch m_StopWatch.Stop(); m_GlyphRenderingGenerationTime = m_StopWatch.Elapsed.TotalMilliseconds; - Debug.Log("Font Atlas generation completed in: " + m_GlyphRenderingGenerationTime.ToString("0.000 ms.")); + m_IsGlyphRenderingDone = true; + //Debug.Log("Font Atlas generation completed in: " + m_GlyphRenderingGenerationTime.ToString("0.000 ms.")); m_StopWatch.Reset(); }); } diff --git a/Scripts/Runtime/TMP_SubMesh.cs b/Scripts/Runtime/TMP_SubMesh.cs index e8272ac..50098c2 100644 --- a/Scripts/Runtime/TMP_SubMesh.cs +++ b/Scripts/Runtime/TMP_SubMesh.cs @@ -232,6 +232,32 @@ public TMP_Text textComponent private bool m_isRegisteredForEvents; + public static TMP_SubMesh AddSubTextObject(TextMeshPro textComponent, MaterialReference materialReference) + { + GameObject go = new GameObject("TMP SubMesh [" + materialReference.material.name + "]", typeof(TMP_SubMesh)); + go.hideFlags = HideFlags.DontSave; + + TMP_SubMesh subMesh = go.GetComponent(); + + go.transform.SetParent(textComponent.transform, false); + go.transform.localPosition = Vector3.zero; + go.transform.localRotation = Quaternion.identity; + go.transform.localScale = Vector3.one; + go.layer = textComponent.gameObject.layer; + + subMesh.m_TextComponent = textComponent; + subMesh.m_fontAsset = materialReference.fontAsset; + subMesh.m_spriteAsset = materialReference.spriteAsset; + subMesh.m_isDefaultMaterial = materialReference.isDefaultMaterial; + subMesh.SetSharedMaterial(materialReference.material); + + subMesh.renderer.sortingLayerID = textComponent.renderer.sortingLayerID; + subMesh.renderer.sortingOrder = textComponent.renderer.sortingOrder; + + return subMesh; + } + + void OnEnable() { //Debug.Log("***** OnEnable() called on object ID " + GetInstanceID() + "]. Parent Text Object ID [" + (textComponent == null ? "" : textComponent.GetInstanceID().ToString()) + "] *****"); @@ -252,6 +278,10 @@ void OnEnable() m_isRegisteredForEvents = true; } + // Update HideFlags on previously created sub text objects. + if (hideFlags != HideFlags.DontSave) + hideFlags = HideFlags.DontSave; + // Make the geometry visible when the object is enabled. meshFilter.sharedMesh = mesh; @@ -420,33 +450,6 @@ void ON_TMP_SETTINGS_CHANGED() #endif - - public static TMP_SubMesh AddSubTextObject(TextMeshPro textComponent, MaterialReference materialReference) - { - GameObject go = new GameObject("TMP SubMesh [" + materialReference.material.name + "]", typeof(TMP_SubMesh)); - go.hideFlags = HideFlags.DontSave; - - TMP_SubMesh subMesh = go.GetComponent(); - - go.transform.SetParent(textComponent.transform, false); - go.transform.localPosition = Vector3.zero; - go.transform.localRotation = Quaternion.identity; - go.transform.localScale = Vector3.one; - go.layer = textComponent.gameObject.layer; - - subMesh.m_TextComponent = textComponent; - subMesh.m_fontAsset = materialReference.fontAsset; - subMesh.m_spriteAsset = materialReference.spriteAsset; - subMesh.m_isDefaultMaterial = materialReference.isDefaultMaterial; - subMesh.SetSharedMaterial(materialReference.material); - - subMesh.renderer.sortingLayerID = textComponent.renderer.sortingLayerID; - subMesh.renderer.sortingOrder = textComponent.renderer.sortingOrder; - - return subMesh; - } - - public void DestroySelf() { Destroy(this.gameObject, 1f); diff --git a/Scripts/Runtime/TMP_SubMeshUI.cs b/Scripts/Runtime/TMP_SubMeshUI.cs index 5a9068a..2fb773d 100644 --- a/Scripts/Runtime/TMP_SubMeshUI.cs +++ b/Scripts/Runtime/TMP_SubMeshUI.cs @@ -266,6 +266,10 @@ protected override void OnEnable() m_isRegisteredForEvents = true; } + // Update HideFlags on previously created sub text objects. + if (hideFlags != HideFlags.DontSave) + hideFlags = HideFlags.DontSave; + m_ShouldRecalculateStencil = true; RecalculateClipping(); RecalculateMasking(); diff --git a/Scripts/Runtime/TMPro_Private.cs b/Scripts/Runtime/TMPro_Private.cs index ba9e4b8..c6caa02 100644 --- a/Scripts/Runtime/TMPro_Private.cs +++ b/Scripts/Runtime/TMPro_Private.cs @@ -1389,9 +1389,14 @@ public override void ComputeMarginSize() if (this.rectTransform != null) { //Debug.Log("*** ComputeMarginSize() *** Current RectTransform's Width is " + m_rectTransform.rect.width + " and Height is " + m_rectTransform.rect.height); // + " and size delta is " + m_rectTransform.sizeDelta); + Rect rect = m_rectTransform.rect; - m_marginWidth = m_rectTransform.rect.width - m_margin.x - m_margin.z; - m_marginHeight = m_rectTransform.rect.height - m_margin.y - m_margin.w; + m_marginWidth = rect.width - m_margin.x - m_margin.z; + m_marginHeight = rect.height - m_margin.y - m_margin.w; + + // Cache current RectTransform width and pivot referenced in OnRectTransformDimensionsChange() to get around potential rounding error in the reported width of the RectTransform. + m_PreviousRectTransformSize = rect.size; + m_PreviousPivotPosition = m_rectTransform.pivot; // Update the corners of the RectTransform m_RectTransformCorners = GetTextContainerLocalCorners(); @@ -1431,9 +1436,6 @@ protected override void OnRectTransformDimensionsChange() return; } - m_PreviousRectTransformSize = m_rectTransform.rect.size; - m_PreviousPivotPosition = m_rectTransform.pivot; - ComputeMarginSize(); SetVerticesDirty(); diff --git a/Scripts/Runtime/TMPro_UGUI_Private.cs b/Scripts/Runtime/TMPro_UGUI_Private.cs index 1c4ac90..e499dbb 100644 --- a/Scripts/Runtime/TMPro_UGUI_Private.cs +++ b/Scripts/Runtime/TMPro_UGUI_Private.cs @@ -1467,9 +1467,14 @@ public override void ComputeMarginSize() if (this.rectTransform != null) { //Debug.Log("*** ComputeMarginSize() *** Current RectTransform's Width is " + m_rectTransform.rect.width + " and Height is " + m_rectTransform.rect.height); // + " and size delta is " + m_rectTransform.sizeDelta); + Rect rect = m_rectTransform.rect; - m_marginWidth = m_rectTransform.rect.width - m_margin.x - m_margin.z; - m_marginHeight = m_rectTransform.rect.height - m_margin.y - m_margin.w; + m_marginWidth = rect.width - m_margin.x - m_margin.z; + m_marginHeight = rect.height - m_margin.y - m_margin.w; + + // Cache current RectTransform width and pivot referenced in OnRectTransformDimensionsChange() to get around potential rounding error in the reported width of the RectTransform. + m_PreviousRectTransformSize = rect.size; + m_PreviousPivotPosition = m_rectTransform.pivot; // Update the corners of the RectTransform m_RectTransformCorners = GetTextContainerLocalCorners(); @@ -1535,9 +1540,6 @@ protected override void OnRectTransformDimensionsChange() return; } - m_PreviousRectTransformSize = m_rectTransform.rect.size; - m_PreviousPivotPosition = m_rectTransform.pivot; - ComputeMarginSize(); UpdateSubObjectPivot(); @@ -4510,9 +4512,12 @@ internal override Rect GetCanvasSpaceClippingRect() Transform rootCanvasTransform = m_canvas.rootCanvas.transform; Bounds compoundBounds = GetCompoundBounds(); - Vector3 position = rootCanvasTransform.InverseTransformPoint(m_rectTransform.position); + Vector2 position = rootCanvasTransform.InverseTransformPoint(m_rectTransform.position); + + Vector2 canvasLossyScale = rootCanvasTransform.lossyScale; + Vector2 lossyScale = m_rectTransform.lossyScale / canvasLossyScale; - return new Rect(position + compoundBounds.min, compoundBounds.size); + return new Rect(position + compoundBounds.min * lossyScale, compoundBounds.size * lossyScale); } diff --git a/Scripts/Runtime/TextMeshProUGUI.cs b/Scripts/Runtime/TextMeshProUGUI.cs index b5acf45..04370c8 100644 --- a/Scripts/Runtime/TextMeshProUGUI.cs +++ b/Scripts/Runtime/TextMeshProUGUI.cs @@ -369,7 +369,7 @@ public override void RecalculateMasking() public override void Cull(Rect clipRect, bool validRect) { //Debug.Log("***** Cull (" + clipRect + ", " + validRect + ") Cull: " + m_canvasRenderer.cull + " *****"); - if (m_canvas == null) + if (m_canvas == null || m_canvas.rootCanvas == null) return; // Get compound rect for the text object and sub text objects in local canvas space. diff --git a/package.json b/package.json index 50f71d1..7042761 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.textmeshpro", "displayName": "TextMeshPro", - "version": "2.1.0-preview.12", + "version": "2.1.0-preview.13", "unity": "2019.1", "description": "TextMeshPro is the ultimate text solution for Unity. It's the perfect replacement for Unity's UI Text and the legacy Text Mesh.\n\nPowerful and easy to use, TextMeshPro (also known as TMP) uses Advanced Text Rendering techniques along with a set of custom shaders; delivering substantial visual quality improvements while giving users incredible flexibility when it comes to text styling and texturing.\n\nTextMeshPro provides Improved Control over text formatting and layout with features like character, word, line and paragraph spacing, kerning, justified text, Links, over 30 Rich Text Tags available, support for Multi Font & Sprites, Custom Styles and more.\n\nGreat performance. Since the geometry created by TextMeshPro uses two triangles per character just like Unity's text components, this improved visual quality and flexibility comes at no additional performance cost.", "keywords": [ @@ -18,9 +18,9 @@ "repository": { "type": "git", "url": "https://github.cds.internal.unity3d.com/unity/com.unity.textmeshpro.git", - "revision": "519a80532dac6569e4fcd1896045c6eb0f63aba0" + "revision": "2e03ff9e1624d8fb3b464cd212ea2df1d5e16eb0" }, "upmCi": { - "footprint": "d9daa40441a9b101fd60c66787728d95e32eab9e" + "footprint": "efc885a90a536ccd3fe4247316486c23738bdf87" } }