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

UI TEXT Problem

Discussion in 'UGUI & TextMesh Pro' started by Emptiness, Sep 9, 2015.

  1. Emptiness

    Emptiness

    Joined:
    Jul 14, 2012
    Posts:
    33
    Dear fellow Unity friends :)

    I've encountered a bit annoying problem so I hope someone can help me.

    I'm developing a kinda tower defense game for Android.
    During game-play I'd like to let the user to open the info UI panel which contains description about items, buildings and enemies ...

    My problem is when I create only 15 item boxes with description in the UI and an additional general text these costs almost 40000 vertices!?

    Obviously this is too much vertices for an android game and the scene is not even included the actual game itself! So I must do something terribly wrong :)

    I've made an example scene to illustrate the problem.

    The first image shows that a simple whole screen text costs ~10 000 vertices!
    textProblem01.jpg

    The second image shows that a simple whole screen text and only 15 simple item boxes costs ~40 000 vertices!
    textProblem02.jpg

    I found out that every single letter cost 4 vertices.
    I could make disappear the elements which are not visible to make the rendering much faster but the elements would still use the device memory.

    Can anyone help me what am I doing wrong?

    I've attached the test project to make this case clear.
    Thanks.
    /ps: I don't even mention that after upgraded from 5.1.3 to 5.2 UI performance become much worse :( /
     

    Attached Files:

    Last edited: Sep 9, 2015
  2. Emptiness

    Emptiness

    Joined:
    Jul 14, 2012
    Posts:
    33
    I'm still struggling whit this problem.
    Is there anyone who could help to solve this?
    I'd really appreciate it.
    Thank you.
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    So a character does need 4 verts to draw just how the system works. if items are off screen try adding a rect mask 2d to the canvas to clip elements outside which should help.
     
  4. Emptiness

    Emptiness

    Joined:
    Jul 14, 2012
    Posts:
    33
    Thank you for your answer.

    I've already written a code which handles texts located outside the canvas, but the rect mask 2d looks really interesting so I'm going to use it. Thanks. :)

    But it's still troublesome on mobile devices that a full screen description alone could use 10k vertices.
    I'm curious, is there any chance to optimize this in the future releases?
    For example:
    Since all text components are on a rectangle (RectTransform), wouldn't be effective to render all the
    characters related a text component on one rectangle?

    I don't really know how unity draws characters, so maybe this idea makes it slower to render the characters on the screen.

    Thanks.
     
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Text is done using glyps. As we need to grab different UV's for each character we need 4 verts per character.