diff --git a/README.md b/README.md index 454e909..90bc0bb 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,8 @@ There are almost 70+ extension controls / effect and other utilities in the proj |NicerOutline|RaycastMask|UIFlippable|UIImageCrop|SoftAlphaMask| |CylinderText|UIParticleSystem|CurlyUI|Shine Effect|Shader Effects| +> Text Effects are not supported with TextMeshPro due to its architecture, try using the native TextMeshPro effects instead. + [Additional Components](https://unity-ui-extensions.github.io/Controls.html#additional-components) |ReturnKeyTrigger|TabNavigation|uGUITools|ScrollRectTweener|ScrollRectLinker| diff --git a/Runtime/Scripts/Effects/CurvedText.cs b/Runtime/Scripts/Effects/CurvedText.cs index b26d01d..1f69c7e 100644 --- a/Runtime/Scripts/Effects/CurvedText.cs +++ b/Runtime/Scripts/Effects/CurvedText.cs @@ -1,13 +1,10 @@ /// Credit Breyer /// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1777407 +#if !UNITY_2022_1_OR_NEWER namespace UnityEngine.UI.Extensions { -#if UNITY_2022_1_OR_NEWER - [RequireComponent(typeof(TMPro.TMP_Text))] -#else [RequireComponent(typeof(Text))] -#endif [RequireComponent(typeof(RectTransform))] [AddComponentMenu("UI/Effects/Extensions/Curved Text")] public class CurvedText : BaseMeshEffect @@ -87,3 +84,4 @@ namespace UnityEngine.UI.Extensions } } } +#endif \ No newline at end of file diff --git a/Runtime/Scripts/Effects/CylinderText.cs b/Runtime/Scripts/Effects/CylinderText.cs index 541f8e0..a303cb4 100644 --- a/Runtime/Scripts/Effects/CylinderText.cs +++ b/Runtime/Scripts/Effects/CylinderText.cs @@ -1,14 +1,11 @@ /// adaption for cylindrical bending by herbst /// Credit Breyer /// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1777407 +#if UNITY_2022_1_OR_NEWER namespace UnityEngine.UI.Extensions { -#if UNITY_2022_1_OR_NEWER - [RequireComponent(typeof(TMPro.TMP_Text))] -#else [RequireComponent(typeof(Text))] -#endif [RequireComponent(typeof(RectTransform))] [AddComponentMenu("UI/Effects/Extensions/Cylinder Text")] public class CylinderText : BaseMeshEffect @@ -57,3 +54,4 @@ namespace UnityEngine.UI.Extensions } } } +#endif \ No newline at end of file diff --git a/Runtime/Scripts/Effects/LetterSpacing.cs b/Runtime/Scripts/Effects/LetterSpacing.cs index e9fea6c..8b3b14e 100644 --- a/Runtime/Scripts/Effects/LetterSpacing.cs +++ b/Runtime/Scripts/Effects/LetterSpacing.cs @@ -40,7 +40,7 @@ use HTML-like tags in your text. Try it out, you'll see what I mean. It doesn't break down entirely, but it doesn't really do what you'd want either. */ - +#if !UNITY_2022_1_OR_NEWER using System.Collections.Generic; namespace UnityEngine.UI.Extensions @@ -74,6 +74,11 @@ namespace UnityEngine.UI.Extensions } } + protected override void Awake() + { + Debug.Log($"Awake, [{m_spacing}]"); + } + public override void ModifyMesh(VertexHelper vh) { if (! IsActive()) return; @@ -81,11 +86,8 @@ namespace UnityEngine.UI.Extensions List verts = new List(); vh.GetUIVertexStream(verts); -#if UNITY_2022_1_OR_NEWER - var text = GetComponent(); -#else var text = GetComponent(); -#endif + if (text == null) { Debug.LogWarning("LetterSpacing: Missing Text component"); @@ -98,28 +100,6 @@ namespace UnityEngine.UI.Extensions float alignmentFactor = 0; int glyphIdx = 0; -#if UNITY_2022_1_OR_NEWER - switch (text.alignment) - { - case TMPro.TextAlignmentOptions.BottomLeft: - case TMPro.TextAlignmentOptions.MidlineLeft: - case TMPro.TextAlignmentOptions.TopLeft: - alignmentFactor = 0f; - break; - - case TMPro.TextAlignmentOptions.BottomJustified: - case TMPro.TextAlignmentOptions.MidlineJustified: - case TMPro.TextAlignmentOptions.TopJustified: - alignmentFactor = 0.5f; - break; - - case TMPro.TextAlignmentOptions.BottomRight: - case TMPro.TextAlignmentOptions.MidlineRight: - case TMPro.TextAlignmentOptions.TopRight: - alignmentFactor = 1f; - break; - } -#else switch (text.alignment) { case TextAnchor.LowerLeft: @@ -140,8 +120,7 @@ namespace UnityEngine.UI.Extensions alignmentFactor = 1f; break; } -#endif - + for (int lineIdx=0; lineIdx < lines.Length; lineIdx++) { string line = lines[lineIdx]; @@ -193,3 +172,4 @@ namespace UnityEngine.UI.Extensions } } } +#endif \ No newline at end of file diff --git a/Runtime/Scripts/Effects/MonoSpacing.cs b/Runtime/Scripts/Effects/MonoSpacing.cs index 465f547..66877dd 100644 --- a/Runtime/Scripts/Effects/MonoSpacing.cs +++ b/Runtime/Scripts/Effects/MonoSpacing.cs @@ -40,17 +40,14 @@ use HTML-like tags in your text. Try it out, you'll see what I mean. It doesn't break down entirely, but it doesn't really do what you'd want either. */ +#if !UNITY_2022_1_OR_NEWER using System.Collections.Generic; namespace UnityEngine.UI.Extensions { [AddComponentMenu("UI/Effects/Extensions/Mono Spacing")] -#if UNITY_2022_1_OR_NEWER - [RequireComponent(typeof(TMPro.TMP_Text))] -#else [RequireComponent(typeof(Text))] -#endif [RequireComponent(typeof(RectTransform))] ///Summary /// Note, Vertex Count has changed in 5.2.1+, is now 6 (two tris) instead of 4 (tri strip). @@ -62,21 +59,15 @@ namespace UnityEngine.UI.Extensions public bool UseHalfCharWidth = false; private RectTransform rectTransform; -#if UNITY_2022_1_OR_NEWER - private TMPro.TMP_Text text; -#else + private Text text; -#endif protected MonoSpacing() { } protected override void Awake() { -#if UNITY_2022_1_OR_NEWER - text = GetComponent(); -#else text = GetComponent(); -#endif + if (text == null) { Debug.LogWarning("MonoSpacing: Missing Text component"); @@ -117,28 +108,6 @@ namespace UnityEngine.UI.Extensions float alignmentFactor = 0; int glyphIdx = 0; -#if UNITY_2022_1_OR_NEWER - switch (text.alignment) - { - case TMPro.TextAlignmentOptions.BottomLeft: - case TMPro.TextAlignmentOptions.MidlineLeft: - case TMPro.TextAlignmentOptions.TopLeft: - alignmentFactor = 0f; - break; - - case TMPro.TextAlignmentOptions.BottomJustified: - case TMPro.TextAlignmentOptions.MidlineJustified: - case TMPro.TextAlignmentOptions.TopJustified: - alignmentFactor = 0.5f; - break; - - case TMPro.TextAlignmentOptions.BottomRight: - case TMPro.TextAlignmentOptions.MidlineRight: - case TMPro.TextAlignmentOptions.TopRight: - alignmentFactor = 1f; - break; - } -#else switch (text.alignment) { case TextAnchor.LowerLeft: @@ -159,7 +128,7 @@ namespace UnityEngine.UI.Extensions alignmentFactor = 1f; break; } -#endif + for (int lineIdx=0; lineIdx < lines.Length; lineIdx++) { string line = lines[lineIdx]; @@ -221,4 +190,5 @@ namespace UnityEngine.UI.Extensions vh.AddUIVertexTriangleStream(verts); } } -} \ No newline at end of file +} +#endif \ No newline at end of file