Search Unity

Unity UI Truncate beginning of UI text, or accurately calculate visible line count

Discussion in 'UGUI & TextMesh Pro' started by gumboots, Sep 17, 2020.

  1. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Hi all,

    I'm hoping there's a way to truncate the beginning of a UI text. I'm creating what is essentially a console, and have the text element aligned to the bottom. Once it fills the screen however, it begins cutting off the newer text, rather than the text that is overflowing up. Is there anyway to reverse this functionality?

    Alternatively, is there an accurate way to count the visible lines, resolution-independent? (I am using a monospaced font, which I assume should make it easier.)

    Thanks!
     
    Madsen87 likes this.
  2. Madsen87

    Madsen87

    Joined:
    Jan 6, 2019
    Posts:
    15
    Hey, Gumboots. I realise I'm arriving many months too late with an answer, but I'm doing a project with a console, and I ran into your question (which was also mine), so in case anyone else comes to this, here's my 2 cents. The easiest solution I found was to put the console output into "overflow", and then use a mask so that the console content would only appear while inside the mask (which is also the limits of the console window). Might seem a bit crude, but, if it works, it works.