Search Unity

Question Is there a way to make TextMeshPro visible in Prefab Preview?

Discussion in 'UGUI & TextMesh Pro' started by AnAngelineer, Apr 23, 2023.

  1. AnAngelineer

    AnAngelineer

    Joined:
    Nov 4, 2015
    Posts:
    34
    When creating a prefab with textMeshpro, the text can not be seen in the preview that appears in the asset folder. It also can't appear on previews used with the "Odin Serializer" tool. (I am pretty sure those display the same thing).

    My app's data entry would benefit a LOT from being able to see the text as a preview. So I wanted to ask if there a way to change the textmeshpro components so that they will appear on prefab previews?

    Thanks.
     
  2. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    If you drop the mouse into the preview and click and drag to arc rotate the invisible objects, does the TMP object appear? It might, by default, be facing the other way in the preview/prefab than the "camera". There's a bunch of situations where this is a complete pain. Particle systems are another.
     
  3. AnAngelineer

    AnAngelineer

    Joined:
    Nov 4, 2015
    Posts:
    34
    Hi, thanks for suggesting something, but this didn't work.
    When the Gameobject only has a TextMeshPro, there's not even a preview of the prefab, just a "blue box icon". that seems to indicate that textMeshPro components can't appear in the prefab's preview.

    You can see below what I mean : the prefab is opened in edit mode, and shows its text. below, we can see no preview is generated at all.

    I was wondering if there was a setting to change that, or if the issue is too deep-rooted into the code of either Unity or TMPro in order to do anything.
    noPreview.jpg
     
  4. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    the prefab preview is (I think) only visible when you select the the prefab in the Project folder (not hierarchy, nor when opened) and you have the Inspector open. If you select the Prefab in the Project folder do you see a Preview in the Inspector? If not, you might need to slide up the "bottom edge" so as to reveal the preview.
     
  5. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    Sorry, you're absolutely right. Just checked... a Game Object with nothing other than a TMP component doesn't have a preview:

    Ugly work around... nest the Game Object with the TMP component underneath another game object... this does show up with a Preview.
     
  6. AnAngelineer

    AnAngelineer

    Joined:
    Nov 4, 2015
    Posts:
    34
    Yeah, but that preview doesn't show the text... so in my case this isn't very useful.

    I wonder if the cause is the fact that TextMeshPro relies on "RectTransform" for its position, rather than "Transform"...
     
  7. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    argh. that's odd. I can at least see the TMP objects text when it's a child of a normal game object that doesn't have a RectTransform. As you, I think it's that RectTransform that's causing the issue. If that's the top level of the prefab, it seems to signal "Don't make a preview" to the Editor.
     
  8. AnAngelineer

    AnAngelineer

    Joined:
    Nov 4, 2015
    Posts:
    34
    I'm kind of surprised to hear you say you get text in previews... unless maybe the parent objects must be 3D/meshes? In my case, it's sprites.

    Here you can see my last test. TMP is nested inside. But I still can't see it in preview. :(

    no text.jpg
     
  9. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    I think we have a different understanding of the Preview. I'm talking about the little "rollup" at the bottom of the Inspector that Previews the content of a selected Project selected Prefab.

    What you're calling a preview I'd think of as the Project folder thumbnail.