Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Text Mesh Pro - The Ultimate Text Solution for Unity - Powerful & Flexible - Advanced Text Rendering

Discussion in 'Assets and Asset Store' started by Stephan-B, May 29, 2014.

Thread Status:
Not open for further replies.
  1. ireth_86

    ireth_86

    Joined:
    May 18, 2016
    Posts:
    23
    OMG, I can't believe I did not check something so obvious. *facepalm*
    Thank you very much. It fixed it, of course. :D
     
  2. zxkne

    zxkne

    Joined:
    Jan 27, 2016
    Posts:
    226
    Hello, @Stephan_B

    I'm a developer of an asset that performs smooth masking for Unity UI. I want to add support of TextMesh Pro to my package. I've faced with the fact that TextMeshProUGUI overrides materialForRendering in a way that isn't compatible with the base class (Graphic) behavior: it doesn't respect IMaterialOverride instances on the object.

    The question is: is this intended behavior? Are there chances that it may be changed in future versions? I've tried to inherit from TextMeshProUGUI and override this property according to the Graphic's implementation. It worked. But I'm not sure what other consequences this solution would have. And, anyway, that is very inconvenient to use a custom class instead of standard TextMeshProUGUI to achieve the result.

    I also wrote you PM, but haven't got a reply. So I decided to repeat my question here. Thanks for your attention.
     
    Pavel-Mutel likes this.
  3. s_guy

    s_guy

    Joined:
    Feb 27, 2013
    Posts:
    102
    Awesome package. Quick question:

    Why are some TMPro features non-functional if other, seemingly unrelated settings turned off? For example, Underlay settings have no effect unless the Glow option is enabled? I can turn Glow on (and change settings to yield no visible result) and the Underlay becomes visible.
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    As a form of optimization, the shaders use keywords to enable / disable some of their functionality.

    Depending on the shader you are using, the keywords and functionality groups are "Outline, Underlay, Bevel Group and Glow".

    Underlay is independent of Glow and as such does not require enabling the Glow group. If you are running into this behavior, this could be one of those strange Asset Importer issue which I have run into in the past which can easily be fixed by deleting the "Resources/Shaders" folder and then re-importing just those from the package.
     
    s_guy likes this.
  5. s_guy

    s_guy

    Joined:
    Feb 27, 2013
    Posts:
    102
    This fixed the issue, thanks.
     
  6. SZplaystudios

    SZplaystudios

    Joined:
    Jun 15, 2016
    Posts:
    1
    Hi, I have a set of numbers in PNG format, these have been rendered out, and I am trying to set them as their own font set. I have looked up tutorials for making sprites and reference them as index; but its not what we want. How do I set the numbers as a set of font of their own?
     
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    The ability to easily create font assets from external .fnt and .pgn file isn't supported at this time. I do have plans to provide this functionality when I have time.

    In the meantime, this could be done using a sprite asset where you would assign a unicode value to each of the sprites.

    So step (1) is to create a sprite asset that contains each of the numbers. Then assign the unicode value in (hex) to each of them. See image below using the DropCap Numbers sprite asset included with TMP.

    upload_2017-5-1_18-15-53.png

    Assuming the font asset assigned to the text object does not contain numbers as well as none of the fallbacks assigned to this font nor the fallback and default font asset assigned in the TMP Settings, then it would grab these from the sprite asset (provided it was assigned as the default sprite asset in the TMP Settings or as a fallback to the default sprite asset.

    So using :
    2017-05-01_18-44-38.png

    Since the default font asset or fallbacks listed in the TMP Settings are likely to contain numbers, this makes it tricky to get those sprites / numbers to show up.

    Having said that and given that you can assign a Sprite Asset to individual text objects in the Extra Settings panel, I did modify where the search order would now be :
    (1) Primary assigned Font Asset
    (2) Fallbacks of the Primary Font Asset along with its fallbacks.
    (3) Sprite Asset assigned to the text object along with its fallbacks.
    (4) Fallbacks assigned in the TMP Settings along with their fallbacks.
    (5) Default Font Asset assigned in the TMP Settings along with its fallbacks.
    (7) The default sprite asset assigned in the TMP Settings along with its fallbacks.

    I can have this change included in the next release. In the event you have purchased TMP in the past and thus have access to source code, I can provide the code change for your to make.
     
    Last edited: May 2, 2017
  8. GreatNimbus

    GreatNimbus

    Joined:
    Jul 13, 2013
    Posts:
    13
    Hi,
    Currently when I apply changes to the font material such as adding an underlay to create a shadow effect, it applies to all text objects using that same font. Will i need to generate a whole new font if i want to have a slightly different effect on another text using the font face?
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    See FAQ Question 1 on the TextMesh Pro user forum.

    As per this answer, you will be using Material Presets to control the visual style / appearance of different text object using the same SDF Font Asset.
     
  10. LunarExGames

    LunarExGames

    Joined:
    Feb 18, 2015
    Posts:
    44
    Hello. I'm trying to get Text Mesh Pro to wrap around a Cylinder as a label. I found that there was code for the below... however when I tried it, nothing worked when adjusting the settings. The TMP text just stayed the same. Would love to have an easy way to get it to bend - wrap around a cylinder. Is it possible to send a modified version of that code so it wraps around cylinders? Thanks!

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using TMPro;
    4. public class WarpTextExample : MonoBehaviour
    5. {
    6.     private TMP_Text m_TextComponent;
    7.     public AnimationCurve VertexCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.25f, 2.0f), new Keyframe(0.5f, 0), new Keyframe(0.75f, 2.0f), new Keyframe(1, 0f));
    8.     public float AngleMultiplier = 1.0f;
    9.     public float SpeedMultiplier = 1.0f;
    10.     public float CurveScale = 1.0f;
    11.     void Awake()
    12.     {
    13.         m_TextComponent = gameObject.GetComponent<TMP_Text>();
    14.     }
    15.     void Start()
    16.     {
    17.         StartCoroutine(WarpText());
    18.     }
    19.     private AnimationCurve CopyAnimationCurve(AnimationCurve curve)
    20.     {
    21.         AnimationCurve newCurve = new AnimationCurve();
    22.         newCurve.keys = curve.keys;
    23.         return newCurve;
    24.     }
    25.     /// <summary>
    26.     ///  Method to curve text along a Unity animation curve.
    27.     /// </summary>
    28.     /// <param name="textComponent"></param>
    29.     /// <returns></returns>
    30.     IEnumerator WarpText()
    31.     {
    32.         VertexCurve.preWrapMode = WrapMode.Clamp;
    33.         VertexCurve.postWrapMode = WrapMode.Clamp;
    34.         Mesh mesh = m_TextComponent.textInfo.meshInfo[0].mesh;
    35.         Vector3[] vertices;
    36.         Matrix4x4 matrix;
    37.         m_TextComponent.havePropertiesChanged = true; // Need to force the TextMeshPro Object to be updated.
    38.         CurveScale *= 10;
    39.         float old_CurveScale = CurveScale;
    40.         AnimationCurve old_curve = CopyAnimationCurve(VertexCurve);
    41.         while (true)
    42.         {
    43.             if (!m_TextComponent.havePropertiesChanged && old_CurveScale == CurveScale && old_curve.keys[1].value == VertexCurve.keys[1].value)
    44.             {
    45.                 yield return null;
    46.                 continue;
    47.             }
    48.             old_CurveScale = CurveScale;
    49.             old_curve = CopyAnimationCurve(VertexCurve);
    50.             m_TextComponent.ForceMeshUpdate(); // Generate the mesh and populate the textInfo with data we can use and manipulate.
    51.             TMP_TextInfo textInfo = m_TextComponent.textInfo;
    52.             int characterCount = textInfo.characterCount;
    53.             if (characterCount == 0) continue;
    54.             //vertices = textInfo.meshInfo[0].vertices;
    55.             //int lastVertexIndex = textInfo.characterInfo[characterCount - 1].vertexIndex;
    56.             float boundsMinX = mesh.bounds.min.x;
    57.             float boundsMaxX = mesh.bounds.max.x;
    58.             for (int i = 0; i < characterCount; i++)
    59.             {
    60.                 if (!textInfo.characterInfo[i].isVisible)
    61.                     continue;
    62.                 int vertexIndex = textInfo.characterInfo[i].vertexIndex;
    63.                 // Get the index of the mesh used by this character.
    64.                 int meshIndex = textInfo.characterInfo[i].materialReferenceIndex;
    65.                 vertices = textInfo.meshInfo[meshIndex].vertices;
    66.                 // Compute the baseline mid point for each character
    67.                 Vector3 offsetToMidBaseline = new Vector2((vertices[vertexIndex + 0].x + vertices[vertexIndex + 2].x) / 2, textInfo.characterInfo[i].baseLine);
    68.                 //float offsetY = VertexCurve.Evaluate((float)i / characterCount + loopCount / 50f); // Random.Range(-0.25f, 0.25f);
    69.                 // Apply offset to adjust our pivot point.
    70.                 vertices[vertexIndex + 0] += -offsetToMidBaseline;
    71.                 vertices[vertexIndex + 1] += -offsetToMidBaseline;
    72.                 vertices[vertexIndex + 2] += -offsetToMidBaseline;
    73.                 vertices[vertexIndex + 3] += -offsetToMidBaseline;
    74.                 // Compute the angle of rotation for each character based on the animation curve
    75.                 float x0 = (offsetToMidBaseline.x - boundsMinX) / (boundsMaxX - boundsMinX); // Character's position relative to the bounds of the mesh.
    76.                 float x1 = x0 + 0.0001f;
    77.                 float y0 = VertexCurve.Evaluate(x0) * CurveScale;
    78.                 float y1 = VertexCurve.Evaluate(x1) * CurveScale;
    79.                 Vector3 horizontal = new Vector3(1, 0, 0);
    80.                 //Vector3 normal = new Vector3(-(y1 - y0), (x1 * (boundsMaxX - boundsMinX) + boundsMinX) - offsetToMidBaseline.x, 0);
    81.                 Vector3 tangent = new Vector3(x1 * (boundsMaxX - boundsMinX) + boundsMinX, y1) - new Vector3(offsetToMidBaseline.x, y0);
    82.                 float dot = Mathf.Acos(Vector3.Dot(horizontal, tangent.normalized)) * 57.2957795f;
    83.                 Vector3 cross = Vector3.Cross(horizontal, tangent);
    84.                 float angle = cross.z > 0 ? dot : 360 - dot;
    85.                 matrix = Matrix4x4.TRS(new Vector3(0, y0, 0), Quaternion.Euler(0, 0, angle), Vector3.one);
    86.                 vertices[vertexIndex + 0] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 0]);
    87.                 vertices[vertexIndex + 1] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 1]);
    88.                 vertices[vertexIndex + 2] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 2]);
    89.                 vertices[vertexIndex + 3] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 3]);
    90.                 vertices[vertexIndex + 0] += offsetToMidBaseline;
    91.                 vertices[vertexIndex + 1] += offsetToMidBaseline;
    92.                 vertices[vertexIndex + 2] += offsetToMidBaseline;
    93.                 vertices[vertexIndex + 3] += offsetToMidBaseline;
    94.             }
    95.             // Upload the mesh with the revised information
    96.             m_TextComponent.UpdateVertexData();
    97.             yield return new WaitForSeconds(0.025f);
    98.         }
    99.     }
    100. }
    101.  
     
  11. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Take a look at the existing WarpTextExample.cs script included with TextMesh Pro. Although it doesn't curve the text the way you want it, that can easily be modified.

    This example should work fine although you might have to play with the Curve Scale. This should also be a good example to learn from so you can adapt it to your own needs.
     
  12. LunarExGames

    LunarExGames

    Joined:
    Feb 18, 2015
    Posts:
    44
    Thank you! The WarpTextExample.cs that was included with the asset seemed to work compared to what I was using from the forums. A little tweaking and got the achieved effect.
     
    Stephan_B likes this.
  13. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,131
    @Stephan_B

    I might have run into a bug with the free Unity version of your asset. I am a first time user, so it could also be my mistake.

    Setup
    - Project uses a few custom but bare minimum vertex shaders
    - Project uses TMP Text both in GUI mode and in 3D mode
    - Project uses LiberationSans SDF material
    - Material uses standard TMP/Mobile/Distance Field Shader
    - Unity 5.5.2.f1

    Problem
    - The TMP Text placed on a canvas with Screen Space overlay rendering, is not rendering on top. I.e. it is covered by 3D objects that it should cover instead of being covered

    Observations
    - This might be related to the other TMP text that is used in 3D mode (it seems that the problem has started after I added the 3D TMP pro text to the scene, although they don't display at the same time)
    - Using a standard Unity text on the same canvas does not have the problem
    - Using the TMP Overlay shader also seems to solve the problem

    Any idea?
     
  14. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    This behavior is related to using a mix of both TMP text component and text objects where they the same material preset in multiple rendering space like Overlay, Screen space and World Space. Since a material can only have its ZTest set one way, there is no way to accommodate both types without having to create some other material or instance material.

    See the following post on the TextMesh Pro user forum which provide additional information and how to handle this easily.
     
  15. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,131
    I forgot to mention that I had set up different materials already assuming it could be related.

    But it sounds like this is the issue and I have done it wrong yesterday. Will try again later and report back if the issue persists.

    Thx for fast response!

    EDIT:

    I think I got it working now. But only after creating 2 new materials. I think what confuses me is that the material gets assigned in the Material Preset Drop Down menu and it is difficult to track back, which one it is in the project folder.

    What I have now is 3 Materials in the drop down (besides others I do not use):
    LiberationSans SDF Material --- this seems to be a default material ??? (not sure if it is at all in the project folder)
    LiberationSans SDF Canvas
    LiberationSans SDF World

    What I tried yesterday was to create one additional Material (I used SDF Material and SDF Canvas) and this did not work. Now I use (SDF Canvas and SDF World) and it works. Maybe I just was tired yesterday....
     
    Last edited: May 5, 2017
  16. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    The LiberationSans SDF Material is in fact the default material which is embedded into the Font Asset. I always keep my default materials unmodified (ie. plain white text). I also always set it to use the Mobile SDF Shader.

    Then as you did, I use some naming convention to label my Material Presets like "LiberationSans SDF - WS - Drop Shadow". WS stands for World Space. Then "LiberationSans SDF - Drop Shadow" is the plain one used in all other cases.
     
  17. lakhbir

    lakhbir

    Joined:
    May 15, 2015
    Posts:
    15
    Two or More Outline and Underlay on a single text !

    Hello.
    How can i use double underlay and double outline. I just want to apply two type of outline on the text with different properties ?
     
  18. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    This functionality is not available at this time.

    This is certainly doable by creating additional SDF shaders which would provide these additional channels / layers.
     
    lakhbir likes this.
  19. nick0124

    nick0124

    Joined:
    Jun 25, 2014
    Posts:
    2
    How i can get current caret position in text with tags? I need to set text to subscript and upscript, but i cant get carret posion in text with tags. For example i have text "012345<sub>6</sub>78<sub>9</sub>" if i set caret betwnen 7 and 8 tmPro.caretPosition will return 8, but real cursor position is 19.
     
  20. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    There are two sets of properties to set the caret position.

    Code (csharp):
    1.  
    2. // These are relative to the visible / displayed text.
    3. public int caretPosition;
    4. public int selectionAnchorPosition;
    5.  
    6. //These are relative to the string which includes the tags.
    7.  public int stringPosition;
    8. public int selectionStringAnchorPosition;
    9.  
    See release notes for beta 4 http://digitalnativestudios.com/forum/index.php?topic=1363.msg10122#msg10122
     
  21. skyrusfxg

    skyrusfxg

    Joined:
    Jan 14, 2016
    Posts:
    127
    Hello. I have next errors in editor in my projecta (with empty properties editor window):

    =========================

    NullReferenceException: Object reference not set to an instance of an object
    TMPro.EditorUtilities.TMP_UiEditorPanel.OnInspectorGUI ()
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1229)
    UnityEditor.DockArea:OnGUI()

    =========================

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.GUILayoutUtility.DoGetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:382)
    UnityEngine.GUILayoutUtility.GetRect (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:373)
    UnityEngine.GUILayout.DoButton (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayout.cs:50)
    UnityEngine.GUILayout.Button (System.String text, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayout.cs:46)
    TMPro.EditorUtilities.TMP_BaseShaderGUI.DoPanelHeader (TMPro.EditorUtilities.MaterialPanel panel)
    TMPro.EditorUtilities.TMP_SDFShaderGUI.DoGUI ()
    TMPro.EditorUtilities.TMP_BaseShaderGUI.OnGUI (UnityEditor.MaterialEditor materialEditor, UnityEditor.MaterialProperty[] properties)
    UnityEditor.MaterialEditor.PropertiesGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1421)
    UnityEditor.DockArea:OnGUI()

    ==========================
     

    Attached Files:

  22. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    What version of Unity are you using?
     
  23. skyrusfxg

    skyrusfxg

    Joined:
    Jan 14, 2016
    Posts:
    127
  24. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    I would suggest deleting the "TextMesh Pro" folder and re-importing the package from the Asset Store.

    If the problem persists, you might be getting the wrong version of TextMesh Pro from the Asset Store which is a known bug with the Asset Store.

    To address the Asset Store issue, you will need to
    (1) Open Unity 5.6.
    (2) Log out of your Unity ID account.
    (3) Delete the "TextMesh Pro" folder.
    (4) Close Unity 5.6.
    (5) Open Unity 5.6 again
    (6) Log in to your Unity ID account.
    (7) Import TextMesh Pro from the Asset Store.
     
  25. nick0124

    nick0124

    Joined:
    Jun 25, 2014
    Posts:
    2
    Tanks. It would be great to make some scripting documentation, now i can found only this http://digitalnativestudios.com/textmeshpro/docs/. And also rename stringPosition, to caretStringPosition. I would never have guessed that stringPosition is caret position.
     
  26. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Most of this functionality is documented in the Release Notes or on the TextMesh Pro user forum. However, I do agree that the documentation is seriously lacking and needs an update.

    Having said that, I am feverishly working on the Integrated version of TextMesh Pro which as I have said before is pretty much a full re-write so I won't have time to update the docs until the new integrated version becomes available (months from now).

    Until then, always be sure to check the TextMesh Pro user forum or search the TextMesh Pro threads here. If all fails, just make a post in the "Unity UI & TextMesh Pro" forum section and I'll be there to provide assistance.
     
  27. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    I just downloaded the latest free version in the asset store and tried to add a TextMeshPro in my UI in Unity 5.6.0f3. All characters appear as magenta blocks and the following error message is displayed in the console :

    How can I fix that ?
    Thanks
     

    Attached Files:

  28. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Looks like another Unity Asset Importer issue.

    Delete the current "TextMesh Pro/Resources/Shaders/" folder and re-import the package from the Asset Store and only selecting to re-import the "TextMesh Pro/Resources/Shaders/" folder.
     
  29. Laserschwert

    Laserschwert

    Joined:
    Apr 3, 2017
    Posts:
    5
    As it is now, TMP objects don't react to fog from the scene settings. Is it possible to have text color change based on distance from the camera? I'm having a textblock lying flat stretching into the distance (think Star Wars text crawl), and would like to have a fog-like effect on it, so that the parts of the text that are further away get a different color (a gradient would be even better than just having a "fog color").
     
  30. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    When using either of the "Surface" distance field shaders included with TextMesh Pro, the text should be affected by fog.

    Also take a look at example 18 which uses a different shader where you can use a texture to control the masking of the text. You could use a texture to control the fading of the text at the top / bottom and then scroll the text through its container using the vertex offset Y in the debug section of the shader.

    Just take a look at these two things to experiment with.
     
  31. StridingDragon

    StridingDragon

    Joined:
    Jan 16, 2013
    Posts:
    78
    Whenever I start up Unity 5.6, I get the following error message

    Shader error in 'TextMeshPro/Distance Field': failed to open source file: 'TMPro_Properties.cginc' at line 126 (on glcore)

    I checked and the file TMPro_Properties.cginc exists and is in the TextMesh Pro/Resources/Shader directory.
    Can anyone explain what this is and how to fix this problem?

    Thanks!
     
  32. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    That's another Unity Asset Importer Issue. Normally deleting the whole "TextMesh Pro/Resources/Shaders/" folder and re-importing it fixes the issue.
     
    StridingDragon likes this.
  33. StridingDragon

    StridingDragon

    Joined:
    Jan 16, 2013
    Posts:
    78
    Thanks, Stephan.

    [Update: I fixed the problem. All I had to do was open the TMPro_Properties.gcinc file in the editor and re-save it. After that, the error went away.]
     
    Last edited: May 17, 2017
  34. skrilmps

    skrilmps

    Joined:
    Mar 14, 2017
    Posts:
    11
    I am having some difficulty understanding when/how to get a TextMeshProUGUI object to update/refresh.

    In a script I am instantiating a TextMeshProUGUI that is set to Page mode. I place text in the TMP and then query textInfo.pageCount to see how many pages it uses (call this N). I then have a loop that instantiates an additional N-1 TMP objects (for a total of N TMP objects, the same as the number of pages). The script then sets TMP #1 to display page 1, TMP #2, to display page 2, etc. The reason I'm doing this is that I want a TMP to appear on both the front and back of a Paper object that I'm creating and manipulating in Unity. When the page gets flipped, you can see the text (both on the front and back of the page) being carried along with it. That part works fine.

    When a TMP is out of view, I use setActive(false) and when it is in view I use setActive(true). There are two TMP's Active at any one time, one for a left page and one for a right page.

    What's happening is, for some reason, the first 4 TMP objects work fine, but the fifth one is not displaying the correct page #, even though it has the page # set correctly in the Inspector at runtime.

    In my Update function I've written a loop that calls ForceMeshUpdate() on all N TMP's, and this fixes the problem. But it doesn't seem wise to make N calls to ForceMeshUpdate() on every frame! So where should I put the ForceMeshUpdate() calls? I've tried putting them both right before and/or right after making a TMP Active, and also right before and/or right after making a TMP inactive, but none of these approaches seem to do the trick.

    Does anyone have any suggestions on what might be going on here? Thank you for your help!

    Mark
     
  35. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    869
    Hello,

    I had the original TextMesh Pro that i downloaded from asset store in my project in Unity 5.4, then I upgraded to 5.5 then i start getting error that TextMesh Pro already exist (I guess it now build into Unity somewhere), but now i cant compile and have errors all over the place.

    Can you tell me how i can disable the built in TextMesh pro, so I can keep using the one i had before (the one i downloaded from asset store)?

    Thanks
     
  36. StridingDragon

    StridingDragon

    Joined:
    Jan 16, 2013
    Posts:
    78
    TextMesh Pro is not built into Unity at this point. You still have to download and set it up externally as a plugin.
    Perhaps you should simply delete the entire TMPro directory in your project and reinstall it from scratch.
     
    Stephan_B likes this.
  37. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    upload_2017-5-17_12-48-48.png
    I continue to get this error when I attempt to add a Text mesh pro UI to my canvas. Any idea what's going on? Normal TextMesh pro objects work fine.

    I have tried deleting and reimporting but continue to get the error.

    Running Unity 5.5.1f1
     
  38. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    As per the Release and Upgrade notes, that is the correct procedure. Since the Asset Import is not an installer, it has no idea how to deal with files that should be renamed or removed from a package or things that an installer normally handles.

    So before upgrading, delete the existing "TextMesh Pro" folder. Make sure you backup any file you may have saved in there first. Also always back up your project first. Then import the latest / appropriate release of TMP for your version of Unity.
     
  39. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    That is because you are using the Unity 5.6 version of TextMesh Pro instead of the version for Unity 5.5.

    You most likely ended up with the release for Unity 5.6 due a bug where the Asset Store will give you the Asset Package based on the version of Unity you last logged into. So if you testing Unity 5.6 and logged into your Unity ID using Unity 5.6, even if you are running Unity 5.5, the Asset Store still thinks you are using Unity 5.6.

    To get around this, simply log out of your Unity account. Start Unity 5.5 and then log back into your Unity account using Unity 5.5. Close Unity 5.5 and then re-open it and you should then be getting the correct version from the Asset Store.
     
  40. skrilmps

    skrilmps

    Joined:
    Mar 14, 2017
    Posts:
    11
    As a follow-up question to this, does calling ForceMeshUpdate on a mesh that is the child of an inactive GameObject still update the mesh?

     
  41. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    If the text object is not active, it will not get updated.
     
    skrilmps likes this.
  42. skrilmps

    skrilmps

    Joined:
    Mar 14, 2017
    Posts:
    11
    Thanks for your answer.

    In that case, is it possible to ForceMeshUpdate a TMP object while also keeping it invisible? Or, would I have to call ForceMeshUpdate just as soon as it becomes visible... and can I set up a listener to do that?
     
  43. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    I tried as you said a few times - even logged out and deleted the package in my appdata folder and redownloaded but got the same error so I assume I'm still getting the incorrect package. Is there a direct download anywhere?

    Thanks!
     
  44. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Just send me a PM with your email address and which version of Unity you are using.
     
  45. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Can you provide more insight on what you are trying to accomplish?

    Are you changing the text via script? Help me understand why you need to use ForceMeshUpdate, etc.
     
  46. skrilmps

    skrilmps

    Joined:
    Mar 14, 2017
    Posts:
    11
    I have N TMP objects in Page mode. TMP#1 is set to display page 1. TMP#2 is set to display page 2, etc. The text is assigned in a script because the text is determined at runtime. Each TMP gets assigned the same text as the others, but each has a different pageToDisplay. I am attaching the TMP's to the front and back of "Paper" objects, so that I can create a page-turning effect in Unity where the text follows the paper as it gets flipped. This works fine. Only two TMP objects are typically active at one time, one for the left page and one for the right page. When you start flipping the paper, the next two pages also become active so that you can see the text of the next pages as they come into view.

    The challenge is that not all of the TMP's appear to be displaying the proper page #, even though the page # appears to be set correctly at runtime according to the inspector. I've found that if I ForceMeshUpdate on all N TMP's during every frame, then the problem goes away. I'd rather not call ForceMeshUpdate N times on every frame.
     
  47. skrilmps

    skrilmps

    Joined:
    Mar 14, 2017
    Posts:
    11
    I found my error. Your clue tipped me off when you told me that a TMPro that's inactive will not update when ForceMeshUpdate is called on it. My TMPro's are children of "Paper" gameobjects, and those papers are active/inactive as they become visible and invisible, which means the TMPro objects that are their children are made active/inactive too.

    My error came in the set up of the Papers and TMPro objects. I was creating the Paper first, setting it inactive by default, and THEN adding the TMPro to the Paper and calling ForceMeshUpdate. That ForceMeshUpdate does nothing. Therefore, the TMPro objects aren't displaying the proper text until they become active. So now when I dynamically construct the pages, I add the TMPro's and set up their pageToDisplay and call ForceMeshUpdate BEFORE inactivating the parent page.

    Thanks for your help!
     
  48. Dreamy_T

    Dreamy_T

    Joined:
    Dec 23, 2015
    Posts:
    9
    Hello. I updated unity 5.5 ->5.6.1f1 today.
    You know, updating unity causes many problems.
    I fixed everything except TextMesh Pro problem(I'm free version user).

    "error CS1704: An assembly with the same name `TextMeshPro' has already been imported. Consider removing one of the references or sign the assembly"
    this is my problem.

    I think TextMesh Pro is final-ultimate-perfect solution about 'Text'.
    I read several articles about Unity5.6 compatibility problem.

    And I read Some guy's opinion about the TextMeshPro.DLL setting(unchecking 'any platform'). But it works only on editor. If I try to build the project for android, the 'Already been imported' problem happens again. And the building process stops.

    I imported TMP more than 5 times to get newest version.
    I read the statement "Package has been submitted using Unity 5.3.4, 5.4.0, 5.5.0, and 5.6.0 to improve compatibility within the range of these versions of Unity." on the AssetStore page.

    It it possible to clear the error problem? I'm gonna release my game within 2 weeks but today I've got stuck..
    Is there a newer or better version of TMP? Is this problem has fixed?(I tried to find the fixed version for hours but I failed...)

    Thank you.
    (I know your Asset is the best one of the AssetStore. I love it.)
     
  49. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    When upgrading to a new release, make sure you remove the previous version by deleting the "TextMesh Pro" folder. This is necessary since the Asset Importer is not an installer. Make sure you back up your project first and whatever files / assets you may have saved inside the TextMesh Pro folder hierarchy.

    Once removed, I would suggest closing Unity since it is possible that once the previous dll are loaded, deleting them might not unload them. I'll re-test that today since I uploading new releases today which should be available in the store next week.

    Back on topic, because of the Asset Store bug where it might provide the wrong version of the Asset, since you were logged into your Unity ID from Unity 5.5, it is possible the Asset Store is always giving you the release for Unity 5.5 instead of 5.6. So to get around that, Log out of your Unity ID (account), close Unity and then open Unity 5.6 and log back in. This should get you the correct release.

    In this next release, I will name the dll something like TextMeshPro-1.0.55.56.dll which will make it easy to spot which one was provided by the Asset Store.

    Oh and if the log-in / log-out fails, just PM me your email and I'll send you the release for Unity 5.6.
     
  50. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    869
    Hello,

    Im trying to upgrade Unity from 5.4 to 5.5.3, when i do Im getting this error message when there was none before. I cant use 5.6 because the movie player in that is broken.

    I already tried the solution of logging out of unity 5.4, then logging into 5.5 and re-downloading TextMesh pro from the asset store and this is what i get when i run the project....

    TypeLoadException: Could not load type 'UnityEngine.AdditionalCanvasShaderChannels' from assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
    TMPro.TextMeshProUGUI.OnPreRenderCanvas ()
    TMPro.TextMeshProUGUI.Rebuild (CanvasUpdate update)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:149)
    UnityEngine.UI.ScrollRect:LateUpdate()



    ANOTHER ERROR

    MissingComponentException: There is no 'RectTransform' attached to the "DataInputField Input Caret" game object, but a script is trying to access it.
    You probably need to add a RectTransform to the game object "DataInputField Input Caret". Or your script needs to check if the component is attached before using it.
    UnityEngine.Component.GetComponentsInParent[RectMask2D] (Boolean includeInactive, System.Collections.Generic.List`1 results) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ComponentBindings.gen.cs:142)
    UnityEngine.UI.MaskUtilities.GetRectMaskForClippable (IClippable clippable) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/MaskUtilities.cs:114)
    UnityEngine.UI.MaskableGraphic.UpdateClipParent () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/MaskableGraphic.cs:203)
    UnityEngine.UI.MaskableGraphic.OnEnable () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/MaskableGraphic.cs:122)
    UnityEngine.GameObject:AddComponent()
    TMPro.TMP_InputField:OnEnable()


    ANOTHER ERROR
    Can't add a 'RectTransform' to the "DataInputField Input Caret" game object during Awake when a 'Transform' is already attached.
    You probably need to add a 'RectTransform' to the "DataInputField Input Caret" game object in the editor.


    Anybody knows how to fix???
     
    Last edited: May 19, 2017
Thread Status:
Not open for further replies.