diff --git a/CHANGELOG.md b/CHANGELOG.md index be2b0fe..456479a 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 +## [1.5.0-preview.13] - 2020-05-22 +## [2.1.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. + ## [1.5.0-preview.12] - 2020-05-09 ## [2.1.0-preview.12] ## [3.0.0-preview.12] diff --git a/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs b/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs index a3c6c76..4d895a5 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,7 @@ 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; m_StopWatch.Reset(); m_FontCharacterTable.Clear(); @@ -987,7 +1001,7 @@ 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; 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 6e7a7db..79b8abb 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 e5adcb0..777c202 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 263d4be..c2746cb 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 669ace2..486c0cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.textmeshpro", "displayName": "TextMeshPro", - "version": "1.5.0-preview.12", + "version": "1.5.0-preview.13", "unity": "2018.3", "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": [ @@ -16,9 +16,9 @@ "repository": { "type": "git", "url": "https://github.cds.internal.unity3d.com/unity/com.unity.textmeshpro.git", - "revision": "444244c864ff938304b3482bb64c3df3600770e4" + "revision": "1448aa571d4c804e4ff3209ae469eacc9387338d" }, "upmCi": { - "footprint": "04a5529de6d5e282fa5137b3e48bc77fd9583f98" + "footprint": "458dc7747e3560202d6adcfe1ff6fa55499baad8" } }