Search Unity

Performance of Masking lots of text

Discussion in 'UGUI & TextMesh Pro' started by holyjewsus, Apr 24, 2015.

  1. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    sometimes I need to generate large strings, sometimes thousands of lines long... and update them very frequently, every frame or more.

    I'm looking for a way to update a text component, but have unity only render what is visible, will a mask / scrollview accomplish this? Or is everything rendered first anyway before being clipped?

    Would using an input panel be an acceptable solution?
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    The answer at present is yes and no.
    Yes the Mask will limit what is drawn to the screen and save you rendering, however this just descopes the size of the quad it draws.
    No it will likely not same you processing time as the Text component still does it's draw calculation prior to the mask, it works as if the mask isn't there.

    However, there should be no big performance hit working with a lot of text, it still is only a single quad.
    If you are concerned about performance, then consider using a separate text component for each paragraph or line, manage and the updates at that level, then only update the text components you need to change.
     
  3. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Just to clarify - The text is 4 vertices / 2 triangles per character. The more characters your text object contains, the more triangles will need to be rendered. This can be verified by creating a text object and looking at the Stats - Tris.

    There is also a limit of 65535 vertices per text object which would limit how many characters / lines of text are possible per object.
     
    Last edited: Apr 27, 2015
  4. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    See my comment in previous post about limitation on how many characters each text object can contain.

    The whole text has to be parsed and geometry created and then the masking takes place in the shader to determine which part of the geometry will be visible.

    Can you provide more insight / details on your needs? For instance, are you trying to limit what is visible like displaying only a page of text or just a certain range of lines or characters?
     
  5. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Thanks for that clarification @Stephan B :D
     
  6. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    Screen Shot 2015-04-14 at 5.55.35 PM.png

    I am implementing a visual programming language, when I update the node's output values I print them to text label, I'm currently dumping the text into an input view instead of what you see in the picture, as it seems to me that unity's input field handles rendering/generating only the visible text based of the rect of the input field... What I would like is a very fast scroll window that only generates text as it comes into view.
     
  7. rustofelees

    rustofelees

    Joined:
    Apr 22, 2013
    Posts:
    26
    I'm looking to do something very similar. Did you ever find a good solution?