Search Unity

TextMesh Pro TextMesh object scaling based on overflow page content

Discussion in 'UGUI & TextMesh Pro' started by Bfahome, Sep 29, 2022.

  1. Bfahome

    Bfahome

    Joined:
    Jan 29, 2022
    Posts:
    4
    So I'm working on something where I want to have text bubbles that dynamically resize to their content, to an extent, shrinking vertically for smaller strings and scaling up to a maximum size for longer strings, with any overflow cut into pages. I have pretty much all of this implemented in a way that I'm satisfied with, based on these two tutorials using the Vertical Layout Component, but I'm running into one small problem that's bothering me slightly, and that's that the final page of a long block of text does not dynamically size down to its content even if it's fewer lines of text than on previous pages.

    (There is also a strange effect on any text that uses the
    <page>
    break, which seems to result in it only scaling up to encompass the final page's content, with other pages of content being overflowed as needed if they're too sized-down.)

    Is there some part of this hierarchy structure that I'm missing that would allow it to scale the bubble down to fit the overflow text on a per-page basis, rather than remaining at the same size?

    (Attached are a couple of screenshots of my test case, with the string just being a repeating sequence of "No!" with line breaks between. Once overflowed to the second page it does not resize down to the "shorter" height, staying at the maximum.)
     

    Attached Files:

    • no1.png
      no1.png
      File size:
      24.2 KB
      Views:
      134
    • no2.png
      no2.png
      File size:
      23 KB
      Views:
      131
  2. sirreldar

    sirreldar

    Joined:
    Jan 17, 2019
    Posts:
    9
    @Bfahome I am having this exact same problem. Do you happen to remember if you ever found a solution?
     
  3. Bfahome

    Bfahome

    Joined:
    Jan 29, 2022
    Posts:
    4
    Didn't find one, no.

    My plan right now is to partially mimic what this sort of behavior would be within the dialogue files. All the dialogue is written in the Ink language, so my format will be to have what would have been
    <page>
    breaks instead broken into "continue" breaks in the Ink file. There may still be multiple pages of dialogue per "continue" block, which will probably result in any final page having "too large" a bubble, but at least for the shorter blocks the bubble will resize properly. A relatively simple fix text-wise, as it's just replacing one bit of text file formatting with another, but it does mean that I had to abandon the idea of being able to scroll back through text pages within the speech bubbles (not a huge loss, the style I'm replicating didn't have that) and I did have to rework a bit of my dialogue manager script.