Search Unity

[Solved][Text Mesh Pro] How to determine total page count in page overflow mode?

Discussion in 'Editor & General Support' started by bluefairymediallc, Jun 8, 2022.

  1. bluefairymediallc

    bluefairymediallc

    Joined:
    Dec 10, 2019
    Posts:
    10
    Because of a bug regarding content size fitter not working consistently with an overflow text mesh box, I've decided to have players navigate through my text-heavy game using paging overflow instead of a scroll bar.

    I can control the paging easily enough using the .pageToDisplay value:

    Code (CSharp):
    1.   _text.pageToDisplay = _page;
    Is there any kind of build-in way to know how many pages there are in total so I know when to show a Next button? Ideally I want to be able to provide the player with the current page index compared to the max page index, providing something at the top like (1/3), (2/3), and (3/3) so they know how much more text there is to go through.

    If I can't do that, is there something I can access to determine if there is any displayed text on the current page? I'm seeing that if there are only 4 pages worth of text and I'm on page 5 then the box becomes blank, but how can I figure out what's currently being displayed in the code as opposed to the full text input ( _text.text, _text.GetParsedText(), etc).

    Thanks!
     
    Clebosevic likes this.
  2. bluefairymediallc

    bluefairymediallc

    Joined:
    Dec 10, 2019
    Posts:
    10
    Luckily it seems like I can use .textInfo.pageCount for this purpose. It's a little trickier as it's null the first frame but it works as I need it to.
     
    deeprest and Clebosevic like this.