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

Text Mesh Pro Outside of Canvas

Discussion in 'UGUI & TextMesh Pro' started by ToshoDaimos, Apr 21, 2017.

  1. ToshoDaimos

    ToshoDaimos

    Joined:
    Jan 30, 2013
    Posts:
    679
    I'm considering rewriting my UI backend to avoid using Unity UI at all. This is because its performance is not satisfying. Can Text Mesh Pro input field be used outside of a Canvas? I need this since I want to have custom UI in world space. Will TMP objects batch fast outside of Unity UI context?
     
    RandomParadox likes this.
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I'm pretty sure that I read a post where someone else was asking this, and the author responded that he might look into it if there's a demand, and when he has time.
    No idea about your second question, aside from having read the author say he always strives for equal or better performance (in general) to comparable Unity tools (be it UI or TextMesh).
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The normal TextMeshPro component uses the Mesh Renderer and as such will benefit from dynamic batching. For object in world space, using this component is much more efficient than using a bunch of Canvas in World Space

    My suggestion is to just grab the product and play around with it. Take a look at the example scene "Benchmark Floating Text".

    The TMP Input Field does not work outside of the Canvas although when I have time, I can certainly look into that as almost none of the functionality is related to canvas stuff.
     
  4. konstantin_lozev

    konstantin_lozev

    Joined:
    May 8, 2015
    Posts:
    99
    Hi, sorry to hijack this post, but I am having a similar issue.
    I am building a 3d Minesweeper game and for bigger levels I have many nodes, even more linerenderers and when you open the nodes each has to show the number of adjacent mines. I managed to get GPU instancing to work with my basic unlit shader and I saw (expectedly) tremendous gains in batching. The linerenderers batch well enough in dynamic batching too.
    However, I get severe framerate dip and spike in the number of batches (from 8 to 611 in the attached screenshot) when the text element on each node gets shown.
    Here is a screenshot with the text elements visible: https://imgur.com/j2Lakvi
    And a screenshot with the text element disabled: https://imgur.com/4Rtd9U7
    I understood that the standard text fields in Unity in my case cannot get batched since they are each on a separate canvas.
    Does Text Mesh Pro support world-space text that can be dynamically changed in runtime and batched?
    Thanks in advance.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Yes. Take a look at example "Benchmark (Floating Text) included with TextMesh Pro and located in the "TMP Examples and Extras".
     
  6. konstantin_lozev

    konstantin_lozev

    Joined:
    May 8, 2015
    Posts:
    99
    Thanks :) Will have a look at the example. I am new to Text Mesh Pro and all the options are a bit overwhelming, so thanks for the pointer :)
     
  7. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    I too am creating a text box under a gameobject and do not want to use canvas. But when I drag a text object from a canvas to a GO the text disappears. The camera to object alignments are correct and the text box is in front of the GO.
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The <TextMeshProUGUI> text component found under "Create - UI - Text - TextMeshPro" is designed to work with the Canvas. This text component only works with the Canvas.

    The <TextMeshPro> text component found under "Create - 3D Object - Text - TextMeshPro" is designed with the Mesh Renderer (ie. this component should be used when not using the Canvas system).

    Also take note of the sorting options in designed to work with the Mesh Renderer. These are Sorting Layer ID and Sorting Order located in the Extra Settings panel of the text object.
     
    Vad3rInHale, AB498, d3x7er and 2 others like this.
  9. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    Thanks. And then I saw it clearly in the instructions.
     
  10. Alex42

    Alex42

    Joined:
    Dec 12, 2013
    Posts:
    2

    Is TMP input/editing in 3D world space without Canvas [already] possible (3D Object TMP InputField)?

    (sorry for posting in an old thread)
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    It is not but most certainly something that would be nice to have.
     
    s4relok and Alex42 like this.