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] A few general questions

Discussion in 'UGUI & TextMesh Pro' started by dadude123, Mar 12, 2017.

  1. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    1.)
    In text mesh pro, what does the "Visible Descender" option do exactly?
    Is it supposed to hide the "bottom" parts of symbols? Or does it affect the vertical line spacing? Or what does it do? Some in-depth explanation would be appreciated.

    2.)
    Is it possible to set the default of "raycast target" to false?
    At least in my project I can't imagine a case where I would want the default to be true.
    In the rare case where I have a text element that should be clickable or has on-hover tooltips or something, I'll enable it manually.

    3.)
    What can we do about allocations?
    I was really happy after I found that a tmp object can be set from a StringBuilder, but after some more testing
    it seems no matter what we do there's still allocations coming from .NET itself when doing for example `5.ToString()`.

    Here's a test, unfortunately it seems the stringbuilder doesn't really help when you want to print numbers...



    Should we write our own caching using an int->string dictionary?
    Or rather just have some method that directly "prints" a given number into a given StringBuilder? (I think that would be best)
    In any case there's not too much we can do for now, unless some things in .net change, right?

    Anyway, what is the intended way to do things when dealing with text that potentially changes every frame?
    With normal unity text there's not much we can do, but since TMP gives us a lot of control, surely there are some optimizations that can be done when using it - best practices.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This only affects tracking of descender of the text when used in conjunction with maxVisibleCharacters which is used in the Old Computer Terminal example scene.

    It is enabled by default like it is for the UI.Text component. It is not possible at this time to change this default although I could easily add the property setting in the TMP Settings file.

    These allocations should only occur in the Editor when using the SetText function as the Text Input Box (Editor inspector) is being kept in sync with the input text. Try a build and all these allocations should go away.

    There is another variant of SetText() which doesn't require the use of stringbuilder which is as follows: SetText("You have earned {0} coins.", m_coins);

    There should be no allocations when changing the text outside of the editor when using SetText. Using the .text property should not either.

    When a text object is created, some allocations occur based on the amount of text. Outside of this initial allocation or when the text grows beyond the initial allocations, there should be no allocations either.
     
    Last edited: Mar 12, 2017
    MattT5 and dadude123 like this.