Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Draw Calls... Shmaw Calls

Discussion in 'UGUI & TextMesh Pro' started by mtalbott, Mar 6, 2015.

  1. mtalbott

    mtalbott

    Joined:
    Dec 21, 2011
    Posts:
    125
    As I work on my Vector Graphics Package, LineWorks, I am becoming aware of all the under-the-hood stuff that the Unity UI is doing to save draw calls and I wanted to share a quick thought on what I have found.

    Simply put, a CanvasRenderer isn't really a Renderer. It's a special component that hands vertices up to the Canvas which has a hidden MeshRenderer that combines all the CanvasRenderer verts into one "Mother-Mesh". That means that all transform information is baked into the "Mother-Mesh" and changed to any canvas elements transform requires rebuilding the "Mother-Mesh". This is why complex scroll rects do not perform well. ie. Every frame that a scroll is happening requires the recalculating and updating of a mesh. And mesh updates are not the cheapest things to so. Alternatively, if CanvasRenderers were more like individual MeshRenderers, you would have a draw call per Renderer but Transform changes would be nearly free.

    As I struggled with this, I had a thought... Maybe after years of complaining about UI draw calls, and finally getting a UI that minimizes them, maybe we've grown out of our need to minimize them. That is, as mobile devices improve, our draw call budgets have increased from a few hundred to now some devices can handle thousands of draw calls reasonably. My last Unity app, Busit!, used the old OnGUI system and probably used several hundred draw calls per frame. However, Busit! has long scroll lists of sometimes hundreds of items and I was able to get it to scroll butter smooth with OnGUI even on an iPhone4.

    Anyway. Just a thought I wanted to share. Maybe it would be a big help if we could choice what gets batched up to the "Mother-Mesh" and what is rendered at the local transform.
     
    Last edited: Mar 6, 2015
    authorthe likes this.
  2. Harito

    Harito

    Joined:
    Mar 3, 2014
    Posts:
    22
    I hope they do allow us to have some items be marked as dynamic... For example, I just found out yesterday that a simple "dancing" back button arrow ( has an Animator based animation that operates on Transform properties ) is causing a pretty big slowdown in an otherwise extremely simple UI screen. It's rebuilding the whole thing just on the account of that little animation :(