Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Textmesh Pro disappear during gameplay

Discussion in 'UGUI & TextMesh Pro' started by MarceloSabadini, Jun 20, 2018.

  1. Superjayjay


    Mar 28, 2013
    Unfortunately that was one of the first things I tried but it didn't change anything. I just checked again to see if I missed any but everything seems to be in order as far as having different material presets is concerned. I also tried duplicating Font Assets and using those, still no luck.

    The text elements aren't the only ones that are bugged either, I have a few images with materials assigned to them that aren't being rendered at all either. I also used the SuperText asset and its text objects are not rendering either.
  2. Stephan_B


    Feb 26, 2017
    Are you using any AssetStore asset that might be trying to batch meshes together or something similar?

    Can you submit a bug report with the project and steps to reproduce so we can take a closer look?
  3. niki_kyl


    Dec 15, 2016
    We had a similar issue, somehow clicking the "Extra Padding" to true solved the issue. Not sure if it works for everyone but worth a try.
  4. Tom163


    Nov 30, 2007
  5. samanabo


    Mar 10, 2015
    We are also experiencing the issue where text will not display if sharing a material preset between TextMeshProUGUI and TextMeshPro components.
    This is made especially confusing when used in conjunction with localization, where a fallback font may be automatically selected. As far as I know there isn't a great way to set a specific fallback materials for a particular text object.
    This inadvertently causes the same material preset to be selected for both kinds of text objects, causing this issue to appear again, depending on the language selected in the game.

    Very interested in any working solutions, or if there are any plans to update or fix this functionality.
  6. Stephan_B


    Feb 26, 2017
    See if you get the same behavior when using the latest preview release of the TMP package which is version 2.2.0-preview.3 for Unity 2019.4 or version 3.2.0-pre.3 for Unity 2020.3 or newer.
    samanabo likes this.
  7. ENOSI_Studio


    Sep 13, 2020
    Change the shader of the material for TMP/Mobile/Bitmap
  8. samanabo


    Mar 10, 2015
    Yes I believe that has fixed the problem for me!

    I am seeing a minor issue still but it seems to only affect the editor (and is not present in builds): World-space text will disappear when the center/pivot of the object goes off screen. My best guess is an issue calculating the bounding box for rendering? The text will reappear once the center of the object is back on screen. However, as you move around and text approaches the edges of the screen you will get a noticeable "flickering". This only appears to happen for text objects that do not have a separate world space material)
    I'm using Unity 2019.4.34f1 and TMP 2.2.0-preview.3

    Again this appears to only occur in the editor so for my purposes it is not a deal breaker.
    Thanks for addressing this!

    Text on the right is visible, since the center of the object is on screen:

    Text on the right is invisible, since center of object is slightly off screen
  9. pohype


    Apr 12, 2019
    Alright I think I found the issue and how to fix it temporarily until the latest TMP beta (which solves the issue for me) is officially released and stable. I only have this issue in WebGL builds.

    When you have TextMeshPro_UGUI elements in you scene (which are screen space elements), and then programmatically add a TextMeshPro element (which is a world space object) in the scene afterwards, you end up messing the default Material because it is used by both. For some reason, the default material is assigned to the TextMeshPro element and some properties of the default material are changed in a way that it works world space but cannot work screen space anymore.

    One easy way to fix this is to clone the default material at the beginning and then each time you add a TextMeshPro element, restoring the properties of the default material with CopyPropertiesFromMaterial:

    Code (CSharp):
    2.     // The default material preset (which can be found under you default font asset)
    3.     // Assign it in the editor
    4.     [SerializeField]
    5.     Material defaultMaterialPreset;
    7.     Material defaultMaterialClone;
    8.     Material worldSpaceMaterial;
    10.     private void Start()
    11.     {
    12.         // Store a clone of the default material to gather its properties later
    13.         defaultMaterialClone = Instantiate(defaultMaterialPreset);
    15.         // Also create a copy of this material to assign it to any created TextMeshPro elements
    16.         worldSpaceMaterial = Instantiate(defaultMaterialPreset);
    17.     }
    19.     private void AddWorldSpaceText()
    20.     {
    21.         GameObject textContainer = new GameObject("Text container test");
    22.         TextMeshPro worldSpaceText = textContainer.AddComponent<TextMeshPro>();
    23.         worldSpaceText.SetText("coucou");
    24.         worldSpaceText.transform.position =;
    25.         worldSpaceText.enableAutoSizing = true;
    26.         worldSpaceText.fontSharedMaterial = worldSpaceMaterial;
    28.         // Make sure you restore the properties of the default material from the clone you made in start
    29.         defaultMaterialPreset.CopyPropertiesFromMaterial(defaultMaterialClone);
    30.     }
    This code has the advantage of working on all existing TextMeshPro_UGUI elements (existing and those who will be created later), instead of having to change their material manually.

    Although this is a quickfix, it would be ideal if we could set a different default material for world space / screen space TMP elements.
  10. JerbearGames1004


    Dec 20, 2021
    Recently just wasted an hour trying to figure out my similar problem. turned out my TextMeshPro was disappearing simply because the scale.z of its parent was being set to 0 due to assigning it as a * value. this was fine when i was using only canvas based things but it will invis any non canvas mesh obviously.

    if anyone is having this issue, be sure to check all transforms including the entire parent heirarchy for the scale.z during runtime :)
  11. DreamcatcherProduciton


    Sep 29, 2016
    That may have been the fix in your case, but it is still an issue on my end, there's no 0 scale on Z.


    (WebGL build)
  12. doctorfunfrock1


    Oct 5, 2014
    @Stephan_B Can you please confirm that this is fixed in the 3.2 prerelease 4 for Unity 2021?
    (I have a ton of fonts for 16 languages and I dynamically switch between them. It would be a pain to create and maintain duplicate material presets.)

    EDIT: as a final note, the manual update to the above mentioned version seems to have fixed it for me (at least no complaints in ~200k android downloads over the last two months)
    Last edited: Apr 24, 2023
  13. AlexStrook


    Oct 19, 2013
    2020.3.21f + URP

    I had the issue of disappering text and UI, I've been tring to fix it for weeks on my project...Turns out creating and applying a specific material preset for the TextmeshPro objects in the scene (3D texts, not Canvas Texts) fixed the issue!

    This worked for me, and thanksfully those 3D texts always have the same font because they aren't translated. I have custom fonts fallbacks for some languages, it would have been a pain to make system that switch the material for specific preset when changing languages...
  14. jlarata


    Feb 10, 2023
    this made it for me, after some hours of poor diagnostic of my problem

    thanks Stephan, i hope good things happen to you.
  15. wilczarz_84


    Jan 6, 2017
    Hi @Stephan_B!

    I am affected by this bug in Unity 2023.1.28f1. I do not use TextMeshPro at all, but I have tons of TextMeshProUGUI components. My app uses two canvases - one in 'camera' mode and one in 'overlay' mode.

    Many iOS users reported to me that all the texts get invisible in the popups (canvas with overlay mode). I have never experienced this with my iphones, but it seems to be a problem for many users. I am literally unable to reproduce this, not on devices, not in the editor.

    My canvases share a lot of prefabs, it would be quite hard for me to use separate font assets for each canvas.

    Occasionally, I do some tweens on ui elements sometimes, like scaling, coloring etc.
    Can this be a problem?
  16. wilczarz_84


    Jan 6, 2017
    So this is how my screen is supposed to look like:

    and this is what happens to it (sent to me by user)

    You can see that all TextMeshProUGUI components disappeared. The one that's left (showing "12") is a regular Text component.
    • This only happens in Canvas with Overlay mode
    • There is a second canvas (camera mode) available in my scene which is not affected
    • I am unable to reproduce it on my iPhone (can be device specific?)
    • Users report that when this bug happens, restarting the app does not help
    • I do not use TextMeshPro component. Only TextMeshProUGUI. Ocaasionally "Text"
    • All TextMeshProUGUI components share the same font asset
    Should I migrate all texts on Overlay canvas from TextMeshProUGUI to Text? This will be LOTS of work. And isn't Text deprecated?

    What can I do to eliminate this? Please help, I'm out of ideas and I cannot reproduce this bug on my devices :(
    Last edited: Aug 23, 2023
    Grafos likes this.
  17. forestluch


    Jan 22, 2015
    I got the same problem, in my device only happens on iphone14.
    do you find the solution?
  18. Mikejmc


    Mar 2, 2015
    I experienced a similar issue, but specifically with the InputField(TMP) in a World Space Canvas.

    In my case, the fix was to remove opposing rotations from the Rect Transforms.

    This is replicable in the editor. Create a Word Space Canvas. Create and populate an InputField(TMP). Rotate the canvas away from you then rotate the InputField back towards you. The InputField should be facing you again, but it stops rendering correctly from either direction. Other TextMeshPro elements are ok.
  19. CargoRunner


    Feb 8, 2021
    I have the same problem. I am new to Unity and I am using Unity 2022.2.5f1.122.8802. And TextMeshPro 3.06. I have created a number of gameplay and menu scenes that have "TextMeshPro - TextUI" elements. These have all worked with no issue. These scenes only use "TextMeshPro - TextUI" elements. The last couple of days I created a new scene that is some instructions. It only contains "TextMeshPro - Text" elements. After completing this scene I tested the whole game. The UI elements did not display in any of the previously completed and previously working scenes. The UI text is visible and correct in the "Scene" view and is missing in the "Game" view and is missing when running the scene. The only exception is one scene where one UI text element is not displayed (like all the other scenes) but one UI text element is rendered as black squares instead of letters in the "Game" view.

    After reading this thread I tried changing the "Font Asset" property in all the "TextMeshPro - TextUI" elements. So that the two types of element used different fonts. On changing the Font Asset the invisible UI text appears in the "Game" view and when running the scene. After getting all the older scenes working again I went back to the new instructions scene. The "TextMeshPro - Text" elements are now just white squares in the "Scene View", "Game" view and when running the scene.

    Is there any step by step instructions on how to get both "TextMeshPro - Text" and "TextMeshPro - TextUI" working in the same project. I do not want them both in the same scene. But I need both normal text and UI text in my project as a whole.

    Attached Files:

    Last edited: Mar 5, 2024
  20. CargoRunner


    Feb 8, 2021
    To try & fix the problem that I cannot get both TextMeshPro Text and TextUI items to both work in my project. I have used the Windows->TextMeshPro->Font Asset Creator to create a new font asset. This creates a new font material as part of the new font asset. This seems to be a recommended solution in past posts. This has not solved the problem. Currently scenes using TextUI are still displaying correctly but scenes using TextMeshPro Text are not. Using the new font asset the text is now displayed correctly in the "Scene" and "Game" view (instead of white blocks). BUT when I try and run the scene I am getting thousands of "NullReferenceException" errors from the "GetFallbackMaterial" procedure in the "TMP_MaterialManager.cs" script. And so no text is displayed at run time.

    Attached Files:

  21. 30035172


    Jun 25, 2016
    still an issue textmeshpro 3.0.8 & webgl

    normal ui.text is ok, tmpro no

    I tried changing material for the different canvas but didn't work

  22. 30035172


    Jun 25, 2016
    I made a tool to fix, worked for me

    first duplicate your textmeshpro font and call it 3D (use the 3D font for world space canvas, or no canvas)
    then create 'Assets\Editor\FindTextMeshProEditor.cs'
    then go tools > find textmeshpro in scene
    then replace the fonts


    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using TMPro;
    4. using System.Collections.Generic;
    5. using System.Linq;
    7. public class FindTextMeshProEditor : EditorWindow
    8. {
    9.     private Vector2 scrollPosition;
    10.     private Dictionary<string, List<GameObject>> foundObjectsGrouped = new Dictionary<string, List<GameObject>>();
    11.     private TMP_FontAsset selectedFont;
    12.     private Material selectedMaterial;
    14.     [MenuItem("Tools/Find TextMeshPro in Scene")]
    15.     public static void ShowWindow()
    16.     {
    17.         GetWindow<FindTextMeshProEditor>("Find TextMeshPro");
    18.     }
    20.     void OnGUI()
    21.     {
    22.         if (GUILayout.Button("Find All TextMeshPro Components"))
    23.         {
    24.             FindAllTextMeshProComponents();
    25.         }
    27.         if (GUILayout.Button("Clear Results"))
    28.         {
    29.             ClearResults();
    30.         }
    32.         GUILayout.Label("Found Objects:", EditorStyles.boldLabel);
    33.         scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);
    34.         foreach (var pair in foundObjectsGrouped)
    35.         {
    36.             GUILayout.Label(pair.Key, EditorStyles.boldLabel);
    37.             foreach (GameObject obj in pair.Value)
    38.             {
    39.                 EditorGUILayout.ObjectField("Object:", obj, typeof(GameObject), true);
    40.             }
    42.             if (pair.Value.Count > 0)
    43.             {
    44.                 EditorGUI.indentLevel++;
    45.                 DrawFontAndMaterialSelectors(pair.Key, pair.Value);
    46.                 EditorGUI.indentLevel--;
    47.             }
    48.         }
    49.         GUILayout.EndScrollView();
    50.     }
    52.     private void DrawFontAndMaterialSelectors(string key, List<GameObject> objects)
    53.     {
    54.         EditorGUILayout.BeginHorizontal();
    55.         GUILayout.Label("Change Font Asset:", GUILayout.Width(150));
    56.         selectedFont = EditorGUILayout.ObjectField(selectedFont, typeof(TMP_FontAsset), false) as TMP_FontAsset;
    57.         EditorGUILayout.EndHorizontal();
    59.         EditorGUILayout.BeginHorizontal();
    60.         GUILayout.Label("Change Material:", GUILayout.Width(150));
    61.         selectedMaterial = EditorGUILayout.ObjectField(selectedMaterial, typeof(Material), false) as Material;
    62.         EditorGUILayout.EndHorizontal();
    64.         if (GUILayout.Button("Apply Changes"))
    65.         {
    66.             ApplyFontAndMaterialChanges(objects);
    67.         }
    68.     }
    70.     private void ApplyFontAndMaterialChanges(List<GameObject> objects)
    71.     {
    72.         Undo.RecordObjects(objects.ToArray(), "Change TMP Font/Material"); // Prepare for undo
    74.         foreach (GameObject obj in objects)
    75.         {
    76.             // Apply changes to TextMeshProUGUI components (UI TextMeshPro)
    77.             var textComponentsUI = obj.GetComponentsInChildren<TextMeshProUGUI>(true);
    78.             foreach (var textComp in textComponentsUI)
    79.             {
    80.                 if (selectedFont != null)
    81.                 {
    82.                     Undo.RecordObject(textComp, "Change TMP Font");
    83.                     textComp.font = selectedFont;
    84.                     EditorUtility.SetDirty(textComp); // Mark the component as dirty
    85.                 }
    87.                 if (selectedMaterial != null)
    88.                 {
    89.                     Undo.RecordObject(textComp, "Change TMP Material");
    90.                     textComp.fontSharedMaterial = selectedMaterial;
    91.                     EditorUtility.SetDirty(textComp); // Mark the component as dirty
    92.                 }
    93.             }
    95.             // Apply changes to TextMeshPro components (3D TextMeshPro)
    96.             var textComponents3D = obj.GetComponentsInChildren<TextMeshPro>(true);
    97.             foreach (var textComp in textComponents3D)
    98.             {
    99.                 if (selectedFont != null)
    100.                 {
    101.                     Undo.RecordObject(textComp, "Change TMP Font");
    102.                     textComp.font = selectedFont;
    103.                     EditorUtility.SetDirty(textComp); // Mark the component as dirty
    104.                 }
    106.                 if (selectedMaterial != null)
    107.                 {
    108.                     Undo.RecordObject(textComp, "Change TMP Material");
    109.                     textComp.fontSharedMaterial = selectedMaterial;
    110.                     EditorUtility.SetDirty(textComp); // Mark the component as dirty
    111.                 }
    112.             }
    113.         }
    114.     }
    117.     private void FindAllTextMeshProComponents()
    118.     {
    119.         foundObjectsGrouped.Clear(); // Clear the results before searching
    121.         var allTextMeshObjects = FindObjectsOfType<TextMeshPro>().Cast<Component>()
    122.             .Concat(FindObjectsOfType<TextMeshProUGUI>())
    123.             .Select(component => component.gameObject).Distinct();
    125.         foreach (var obj in allTextMeshObjects)
    126.         {
    127.             Canvas parentCanvas = obj.GetComponentInParent<Canvas>();
    128.             string key = parentCanvas != null ? $"Canvas: {}" : "No Canvas";
    130.             if (!foundObjectsGrouped.ContainsKey(key))
    131.             {
    132.                 foundObjectsGrouped[key] = new List<GameObject>();
    133.             }
    134.             foundObjectsGrouped[key].Add(obj);
    135.         }
    137.         if (foundObjectsGrouped.Count == 0)
    138.         {
    139.             Debug.Log("No TextMeshPro components found in the scene.");
    140.         }
    141.     }
    143.     private void ClearResults()
    144.     {
    145.         foundObjectsGrouped.Clear();
    146.     }
    147. }

    Attached Files: