Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Replacing Text with TextMesh Pro

Discussion in 'UGUI & TextMesh Pro' started by newcoder17, Feb 3, 2018.

  1. newcoder17

    newcoder17

    Joined:
    Dec 9, 2017
    Posts:
    103
    I have a page of text that I have quite happily scrolling up and down.
    The layout in the hierarchy is:
    Canvas
    >Panel
    >>Image - not sure how I ended up with this but it has a Scroll Rect on it
    >>>GameObject - with just a rect transform
    >>>>Text - with rect transform, Text, Content Size Fitter, Mesh Renderer

    All I want to do is replace the text with textmesh pro, purely do I can use tags for formatting headings etc and also allowing links within the text.

    I've tried adding text mesh to the Text object above but that didn't show anything.
    I've then added another text mesh object under GameObject and that again doesn't show anything.

    I've tried downloading a font and using that instead of arial, changing colours etc but it shows nothing.
    I've checked colours, font size etc.

    Daft as it sounds the object even seems invisible in my scene too.
    Am I doing something wrong?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    If you are using UI.Text objects (Create - UI - Text), replace those by the TextMeshPro - Text for the UI which is located in "Create - UI - TextMeshPro Text".
     
  3. newcoder17

    newcoder17

    Joined:
    Dec 9, 2017
    Posts:
    103
    I dont seem to have that option.
    From the dropdown I just have UI > Text
    Under 3D Object I have 3D text
    If I go to Add Component on a gameobject and search for text all I see is Text, Text Mesh and GUI text

    Am I missing something?

    Edit: OK, now I realise I have to add it in asset store. I thought it was integral to Unity now. I have it now.
    Thanks
     
  4. newcoder17

    newcoder17

    Joined:
    Dec 9, 2017
    Posts:
    103
    Thanks
    I still dont quite know how to get links to work.
    I've looked at the video tutorial, but when I add the text there is no link.
    eg <link="name">Click Here</link>

    On top of that, I dont undertand how to send it elsewhere in the text?

    I basically want to have a menu, so when you click on it you get taken to whatever part of the document.
    Is this possible?
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The <link> tag simply provides a way to define a portion / block of text that you want to track and possibly interact with. The <link> tag doesn't add any logic or visual treatment as users might want to do different things based on interacting with that block of text.

    Take a look at Example 12 and 12a included with TextMesh Pro. More specifically take a look at how example 12a handles interactions with different portions of the text including characters, words, lines and links. Look at the event handlers and how those work.
     
  6. danielheadbang

    danielheadbang

    Joined:
    Mar 24, 2015
    Posts:
    34
    Hello, I'm having an issue that seems to be related to text update with textmeshpro, I have a text with a link, and hovering it prints me the link, as specified, but when I change the text, it no longer seems to trigger the link events, am I doing something wrong?

    I made the change on the 12a example and it seemed to happen the same

    Is there a way to "update" the events so they trigger on text changes? It seemed to only happen with "onlinkselected" though

    If I can get a help on this it would be much appreciated, thanks in advance
     
  7. danielheadbang

    danielheadbang

    Joined:
    Mar 24, 2015
    Posts:
    34
    It happens on the "new" links it seems, adding a link to the text seems to trigger the old ones, but not the new ones
     
  8. danielheadbang

    danielheadbang

    Joined:
    Mar 24, 2015
    Posts:
    34
    I seem to have fixed it by "resetting" the m_selectedlink to -1 after altering the text, as that seems to be the issue, I don't know if this is the correct way to do it but it worked for me, if there's an "official" way to do it I'll be happy to know

    Regards
     
  9. davemeta

    davemeta

    Joined:
    Jul 17, 2012
    Posts:
    17
    Here is an Editor script that works:

    Setup: Project Settings > TextMeshPro > Settings > Default Font Asset (Set to the TMP font you want to use)

    Usage: 1) Select Text(s) in Hierarchy 2) Select: Tools > Text To TextMeshPro

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEngine.UI;
    4. using TMPro;
    5.  
    6. public class TextToTextMeshPro : Editor
    7. {
    8.     public class TextMeshProSettings
    9.     {
    10.         public bool Enabled;
    11.         public FontStyles FontStyle;
    12.         public float FontSize;
    13.         public float FontSizeMin;
    14.         public float FontSizeMax;
    15.         public float LineSpacing;
    16.         public bool EnableRichText;
    17.         public bool EnableAutoSizing;
    18.         public TextAlignmentOptions TextAlignmentOptions;
    19.         public bool WrappingEnabled;
    20.         public TextOverflowModes TextOverflowModes;
    21.         public string Text;
    22.         public Color Color;
    23.         public bool RayCastTarget;
    24.     }
    25.  
    26.     [MenuItem("Tools/Text To TextMeshPro", false, 4000)]
    27.     static void DoIt()
    28.     {
    29.         if(TMPro.TMP_Settings.defaultFontAsset == null)
    30.         {
    31.             EditorUtility.DisplayDialog("ERROR!", "Assign a default font asset in project settings!", "OK", "");
    32.             return;
    33.         }
    34.  
    35.         foreach(GameObject gameObject in Selection.gameObjects)
    36.         {
    37.             ConvertTextToTextMeshPro(gameObject);
    38.         }
    39.     }
    40.  
    41.     static void ConvertTextToTextMeshPro(GameObject target)
    42.     {
    43.         TextMeshProSettings settings = GetTextMeshProSettings(target);
    44.  
    45.         DestroyImmediate(target.GetComponent<Text>());
    46.  
    47.         TextMeshProUGUI tmp = target.AddComponent<TextMeshProUGUI>();
    48.         tmp.enabled = settings.Enabled;
    49.         tmp.fontStyle = settings.FontStyle;
    50.         tmp.fontSize = settings.FontSize;
    51.         tmp.fontSizeMin = settings.FontSizeMin;
    52.         tmp.fontSizeMax = settings.FontSizeMax;
    53.         tmp.lineSpacing = settings.LineSpacing;
    54.         tmp.richText = settings.EnableRichText;
    55.         tmp.enableAutoSizing = settings.EnableAutoSizing;
    56.         tmp.alignment = settings.TextAlignmentOptions;
    57.         tmp.enableWordWrapping = settings.WrappingEnabled;
    58.         tmp.overflowMode = settings.TextOverflowModes;
    59.         tmp.text = settings.Text;
    60.         tmp.color = settings.Color;
    61.         tmp.raycastTarget = settings.RayCastTarget;
    62.     }
    63.  
    64.     static TextMeshProSettings GetTextMeshProSettings(GameObject gameObject)
    65.     {
    66.         Text uiText = gameObject.GetComponent<Text>();
    67.         if (uiText == null)
    68.         {
    69.             EditorUtility.DisplayDialog("ERROR!", "You must select a Unity UI Text Object to convert.", "OK", "");
    70.             return null;
    71.         }
    72.  
    73.         return new TextMeshProSettings
    74.         {
    75.             Enabled = uiText.enabled,
    76.             FontStyle = FontStyleToFontStyles(uiText.fontStyle),
    77.             FontSize = uiText.fontSize,
    78.             FontSizeMin = uiText.resizeTextMinSize,
    79.             FontSizeMax = uiText.resizeTextMaxSize,
    80.             LineSpacing = uiText.lineSpacing,
    81.             EnableRichText = uiText.supportRichText,
    82.             EnableAutoSizing = uiText.resizeTextForBestFit,
    83.             TextAlignmentOptions = TextAnchorToTextAlignmentOptions(uiText.alignment),
    84.             WrappingEnabled = HorizontalWrapModeToBool(uiText.horizontalOverflow),
    85.             TextOverflowModes = VerticalWrapModeToTextOverflowModes(uiText.verticalOverflow),
    86.             Text = uiText.text,
    87.             Color = uiText.color,
    88.             RayCastTarget = uiText.raycastTarget
    89.         };
    90.     }
    91.  
    92.     static bool HorizontalWrapModeToBool(HorizontalWrapMode overflow)
    93.     {
    94.         return overflow == HorizontalWrapMode.Wrap;
    95.     }
    96.  
    97.     static TextOverflowModes VerticalWrapModeToTextOverflowModes(VerticalWrapMode verticalOverflow)
    98.     {
    99.         return verticalOverflow == VerticalWrapMode.Truncate ? TextOverflowModes.Truncate : TextOverflowModes.Overflow;
    100.     }
    101.  
    102.     static FontStyles FontStyleToFontStyles(FontStyle fontStyle)
    103.     {
    104.         switch (fontStyle)
    105.         {
    106.             case FontStyle.Normal:
    107.                 return FontStyles.Normal;
    108.  
    109.             case FontStyle.Bold:
    110.                 return FontStyles.Bold;
    111.  
    112.             case FontStyle.Italic:
    113.                 return  FontStyles.Italic;
    114.  
    115.             case FontStyle.BoldAndItalic:
    116.                 return FontStyles.Bold | FontStyles.Italic;
    117.         }
    118.  
    119.         Debug.LogWarning("Unhandled font style " + fontStyle);
    120.         return FontStyles.Normal;
    121.     }
    122.  
    123.     static TextAlignmentOptions TextAnchorToTextAlignmentOptions(TextAnchor textAnchor)
    124.     {
    125.         switch (textAnchor)
    126.         {
    127.             case TextAnchor.UpperLeft:
    128.                 return TextAlignmentOptions.TopLeft;
    129.  
    130.             case TextAnchor.UpperCenter:
    131.                 return TextAlignmentOptions.Top;
    132.  
    133.             case TextAnchor.UpperRight:
    134.                 return TextAlignmentOptions.TopRight;
    135.  
    136.             case TextAnchor.MiddleLeft:
    137.                 return TextAlignmentOptions.Left;
    138.  
    139.             case TextAnchor.MiddleCenter:
    140.                 return TextAlignmentOptions.Center;
    141.  
    142.             case TextAnchor.MiddleRight:
    143.                 return TextAlignmentOptions.Right;
    144.  
    145.             case TextAnchor.LowerLeft:
    146.                 return TextAlignmentOptions.BottomLeft;
    147.  
    148.             case TextAnchor.LowerCenter:
    149.                 return TextAlignmentOptions.Bottom;
    150.  
    151.             case TextAnchor.LowerRight:
    152.                 return TextAlignmentOptions.BottomRight;
    153.         }
    154.  
    155.         Debug.LogWarning("Unhandled text anchor " + textAnchor);
    156.         return TextAlignmentOptions.TopLeft;
    157.     }
    158. }
     
  10. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Thank you SO MUCH @davemeta for this :)

    I have made some upgrades I needed though:

    New features:

    - Full UNDO support
    - The converter can now process game objects without a Text component without errors. (it just ignores those objects)
    - An option to recursively process all the children of the selected objects. (even disabled ones if wanted)
    - An option to remove obsolete Text UI effects components. (TextMeshPro uses materials instead for doing these effects)

    So now, with the new options, you can just select all the root objects of a scene and the utility will convert all Text UI components in it to TextMeshPro without breaking a sweat.
    Ideal for upgrading whole scenes quickly.

    Just create a new C# script, name it "TextToTextMeshPro.cs" an copy paste this inside.
    Edit: You need to put the script inside a subfolder named EDITOR so that it is not included in the build.

    Then, run the script from the Unity Editor menu: Tools -> Text To TextMeshPro
    (working on Unity 2021LTS but should work on older versions too.)

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEngine.UI;
    4. using TMPro;
    5.  
    6. public class TextToTextMeshPro : Editor
    7. {
    8.     public class TextMeshProSettings
    9.     {
    10.         public bool Enabled;
    11.         public FontStyles FontStyle;
    12.         public float FontSize;
    13.         public float FontSizeMin;
    14.         public float FontSizeMax;
    15.         public float LineSpacing;
    16.         public bool EnableRichText;
    17.         public bool EnableAutoSizing;
    18.         public TextAlignmentOptions TextAlignmentOptions;
    19.         public bool WrappingEnabled;
    20.         public TextOverflowModes TextOverflowModes;
    21.         public string Text;
    22.         public Color Color;
    23.         public bool RayCastTarget;
    24.     }
    25.  
    26.     static private bool recursive = false;
    27.     static private bool applyOnDisabled = false;
    28.     static private bool removeEffectComponents = false;
    29.  
    30.     [MenuItem("Tools/Text To TextMeshPro", false, 4000)]
    31.     static void DoIt()
    32.     {
    33.         if (TMPro.TMP_Settings.defaultFontAsset == null)
    34.         {
    35.             EditorUtility.DisplayDialog("ERROR!", "Assign a default font asset in project settings!", "OK", "");
    36.             return;
    37.         }
    38.  
    39.         recursive = EditorUtility.DisplayDialog("Text To TextMeshPro", "Process all the children of the selected objects recursively?", "Yes", "No");
    40.         if (recursive) applyOnDisabled = EditorUtility.DisplayDialog("Text To TextMeshPro", "Process disabled objects too?", "Yes", "No");
    41.  
    42.         removeEffectComponents = EditorUtility.DisplayDialog("Text To TextMeshPro", "Remove obsolete component effects Shadow and Outline?\n\nThis components have no effect on TextMeshPro and can be safely removed.\nTo apply shadows and outlines on TextMeshPro components, use different materials instead.", "Yes", "No");
    43.  
    44.         foreach (GameObject gameObject in Selection.gameObjects)
    45.         {
    46.             if (recursive)
    47.             {
    48.                 var childs = gameObject.GetComponentsInChildren<Transform>(applyOnDisabled);
    49.                 foreach (var ch in childs)
    50.                     ConvertTextToTextMeshPro(ch.gameObject);
    51.             }
    52.             else
    53.                 ConvertTextToTextMeshPro(gameObject);
    54.         }
    55.     }
    56.  
    57.     static void ConvertTextToTextMeshPro(GameObject target)
    58.     {
    59.         if (removeEffectComponents)
    60.         {
    61.             var sha = target.GetComponents<UnityEngine.UI.Shadow>();
    62.             foreach (var cmp in sha) Undo.DestroyObjectImmediate(cmp);
    63.             var outl = target.GetComponents<UnityEngine.UI.Outline>();
    64.             foreach (var cmp in outl) Undo.DestroyObjectImmediate(cmp);
    65.         }
    66.  
    67.         Text uiText = target.GetComponent<Text>();
    68.         if (uiText == null) return;
    69.  
    70.  
    71.         TextMeshProSettings settings = GetTextMeshProSettings(uiText);
    72.  
    73.         Undo.RecordObject(target, "Text To TextMeshPro");
    74.         Undo.DestroyObjectImmediate(uiText);
    75.  
    76.         TextMeshProUGUI tmp = target.AddComponent<TextMeshProUGUI>();
    77.         tmp.enabled = settings.Enabled;
    78.         tmp.fontStyle = settings.FontStyle;
    79.         tmp.fontSize = settings.FontSize;
    80.         tmp.fontSizeMin = settings.FontSizeMin;
    81.         tmp.fontSizeMax = settings.FontSizeMax;
    82.         tmp.lineSpacing = settings.LineSpacing;
    83.         tmp.richText = settings.EnableRichText;
    84.         tmp.enableAutoSizing = settings.EnableAutoSizing;
    85.         tmp.alignment = settings.TextAlignmentOptions;
    86.         tmp.enableWordWrapping = settings.WrappingEnabled;
    87.         tmp.overflowMode = settings.TextOverflowModes;
    88.         tmp.text = settings.Text;
    89.         tmp.color = settings.Color;
    90.         tmp.raycastTarget = settings.RayCastTarget;
    91.  
    92.         Debug.Log(target.name + " converted to TextMeshProUGUI");
    93.     }
    94.  
    95.     static TextMeshProSettings GetTextMeshProSettings(Text uiText)
    96.     {
    97.         if (uiText == null)
    98.         {
    99.             EditorUtility.DisplayDialog("ERROR!", "You must select a Unity UI Text Object to convert.", "OK", "");
    100.             return null;
    101.         }
    102.  
    103.         return new TextMeshProSettings
    104.         {
    105.             Enabled = uiText.enabled,
    106.             FontStyle = FontStyleToFontStyles(uiText.fontStyle),
    107.             FontSize = uiText.fontSize,
    108.             FontSizeMin = uiText.resizeTextMinSize,
    109.             FontSizeMax = uiText.resizeTextMaxSize,
    110.             LineSpacing = uiText.lineSpacing,
    111.             EnableRichText = uiText.supportRichText,
    112.             EnableAutoSizing = uiText.resizeTextForBestFit,
    113.             TextAlignmentOptions = TextAnchorToTextAlignmentOptions(uiText.alignment),
    114.             WrappingEnabled = HorizontalWrapModeToBool(uiText.horizontalOverflow),
    115.             TextOverflowModes = VerticalWrapModeToTextOverflowModes(uiText.verticalOverflow),
    116.             Text = uiText.text,
    117.             Color = uiText.color,
    118.             RayCastTarget = uiText.raycastTarget
    119.         };
    120.     }
    121.  
    122.     static bool HorizontalWrapModeToBool(HorizontalWrapMode overflow)
    123.     {
    124.         return overflow == HorizontalWrapMode.Wrap;
    125.     }
    126.  
    127.     static TextOverflowModes VerticalWrapModeToTextOverflowModes(VerticalWrapMode verticalOverflow)
    128.     {
    129.         return verticalOverflow == VerticalWrapMode.Truncate ? TextOverflowModes.Truncate : TextOverflowModes.Overflow;
    130.     }
    131.  
    132.     static FontStyles FontStyleToFontStyles(FontStyle fontStyle)
    133.     {
    134.         switch (fontStyle)
    135.         {
    136.             case FontStyle.Normal:
    137.                 return FontStyles.Normal;
    138.  
    139.             case FontStyle.Bold:
    140.                 return FontStyles.Bold;
    141.  
    142.             case FontStyle.Italic:
    143.                 return FontStyles.Italic;
    144.  
    145.             case FontStyle.BoldAndItalic:
    146.                 return FontStyles.Bold | FontStyles.Italic;
    147.         }
    148.  
    149.         Debug.LogWarning("Unhandled font style " + fontStyle);
    150.         return FontStyles.Normal;
    151.     }
    152.  
    153.     static TextAlignmentOptions TextAnchorToTextAlignmentOptions(TextAnchor textAnchor)
    154.     {
    155.         switch (textAnchor)
    156.         {
    157.             case TextAnchor.UpperLeft:
    158.                 return TextAlignmentOptions.TopLeft;
    159.  
    160.             case TextAnchor.UpperCenter:
    161.                 return TextAlignmentOptions.Top;
    162.  
    163.             case TextAnchor.UpperRight:
    164.                 return TextAlignmentOptions.TopRight;
    165.  
    166.             case TextAnchor.MiddleLeft:
    167.                 return TextAlignmentOptions.Left;
    168.  
    169.             case TextAnchor.MiddleCenter:
    170.                 return TextAlignmentOptions.Center;
    171.  
    172.             case TextAnchor.MiddleRight:
    173.                 return TextAlignmentOptions.Right;
    174.  
    175.             case TextAnchor.LowerLeft:
    176.                 return TextAlignmentOptions.BottomLeft;
    177.  
    178.             case TextAnchor.LowerCenter:
    179.                 return TextAlignmentOptions.Bottom;
    180.  
    181.             case TextAnchor.LowerRight:
    182.                 return TextAlignmentOptions.BottomRight;
    183.         }
    184.  
    185.         Debug.LogWarning("Unhandled text anchor " + textAnchor);
    186.         return TextAlignmentOptions.TopLeft;
    187.     }
    188. }
    189.  

    @Stephan_B maybe you could include this script inside the TextMeshPro package?
    Manually updating a project from Text UI to TextMeshPro is very inconvenient.
     
    Last edited: Dec 8, 2022
  11. Anthroventure

    Anthroventure

    Joined:
    Oct 13, 2013
    Posts:
    6
    @atomicjoe

    Tested and works as intended.
    One bug though, it throws errors during building and needs to be removed from the assets folder. (At least that's how I sorted it out.)

    Thanks so much for this, guys. You've literally just saved me hours!


    (Version 2021.3.10f1)
     
    Last edited: Nov 15, 2022
    atomicjoe likes this.
  12. THE2FUN

    THE2FUN

    Joined:
    Aug 25, 2015
    Posts:
    62
    Thanks this is amazing. I can easily replace my text to TMPtexts. Another already Unity needed thing.
     
  13. vkapoor

    vkapoor

    Joined:
    Jan 1, 2022
    Posts:
    24
    I also removed it from the Assets folder while building
     
  14. hyeoman

    hyeoman

    Joined:
    Jan 23, 2019
    Posts:
    2
    using UnityEngine;
    using TMPro;
    using System.Collections;
    public class Example : MonoBehaviour
    {
    public TextMeshPro text;
    void Start()
    {
    text.text = "Hello world!";
    }
    }
     
  15. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    You need to put the script inside a folder named EDITOR so that it is not included in the build.
    I forgot to say that :p
    Any script inside a subfolder named EDITOR will be removed on builds. (Assets/Editor/ for example)
     
  16. Tomsterk

    Tomsterk

    Joined:
    Nov 23, 2012
    Posts:
    10
    Hey all,

    First of all, great script. Using it to save myself a ton of headache. I have one addition

    if you have fonts all over your project and dont want to use the default font, you can modify the script to include this. It requires that your TMP_FontAssets in your project have the SAME NAME as the fonts your Text components' Fonts.

    ie, if your font is called "Arial", your TMP_FontAsset needs to be named "Arial".

    This method is extremely lazy and quick with no error handling. Use at your own risk

    First, add this to the `TextMeshProSettings` class

    Code (CSharp):
    1.  public TMP_FontAsset Font;
    2.  

    Then replace the GetTextMeshProSettings function with this

    Code (CSharp):
    1. static TextMeshProSettings GetTextMeshProSettings(Text uiText)
    2.     {
    3.         if (uiText == null)
    4.         {
    5.             EditorUtility.DisplayDialog("ERROR!", "You must select a Unity UI Text Object to convert.", "OK", "");
    6.             return null;
    7.         }
    8.         string fontName = uiText.font.name;
    9.         var results = AssetDatabase.FindAssets(fontName + " t:TMP_FontAsset", null);
    10.      
    11.         return new TextMeshProSettings
    12.         {
    13.             Enabled = uiText.enabled,
    14.             FontStyle = FontStyleToFontStyles(uiText.fontStyle),
    15.             FontSize = uiText.fontSize,
    16.             FontSizeMin = uiText.resizeTextMinSize,
    17.             FontSizeMax = uiText.resizeTextMaxSize,
    18.             LineSpacing = uiText.lineSpacing,
    19.             EnableRichText = uiText.supportRichText,
    20.             EnableAutoSizing = uiText.resizeTextForBestFit,
    21.             TextAlignmentOptions = TextAnchorToTextAlignmentOptions(uiText.alignment),
    22.             WrappingEnabled = HorizontalWrapModeToBool(uiText.horizontalOverflow),
    23.             TextOverflowModes = VerticalWrapModeToTextOverflowModes(uiText.verticalOverflow),
    24.             Text = uiText.text,
    25.             Color = uiText.color,
    26.             RayCastTarget = uiText.raycastTarget,
    27.             Font = (TMP_FontAsset)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(results[0]), typeof(TMP_FontAsset))
    28.         };
    29.     }
     
    Last edited: Jun 6, 2023
    atomicjoe likes this.
  17. Jamisco

    Jamisco

    Joined:
    May 21, 2022
    Posts:
    4
    This code work, however, I had a problem where say I had 4 text components in a prefab, the code will successfully replaced the first 3 text components with their TMP counterparts, however, for the fourth text component, the text component will be removed but the TMP counterpart wont be added.

    This simply modification in the DoIt() method should fix this

    Code (CSharp):
    1.             foreach (GameObject gameObject in Selection.gameObjects)
    2.             {
    3.                 if (recursive)
    4.                 {
    5.                     var childs = gameObject.GetComponentsInChildren<Transform>(applyOnDisabled);
    6.                    
    7.                     foreach (var ch in childs)
    8.                         ConvertTextToTextMeshPro(ch.gameObject);
    9.  
    10.                     // added this because it seems the last text component in the prefab will be removed but its tmp counter part will not be added/saved
    11.                     PrefabUtility.SavePrefabAsset(gameObject);
    12.  
    13.                 }
    14.                 else
    15.                     ConvertTextToTextMeshPro(gameObject);
    16.             }