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

Unity UI Unity UI is Slow

Discussion in 'UGUI & TextMesh Pro' started by Zullar, Feb 27, 2019.

  1. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    I have been using Unity's 4.6 UI and am having problems with it being slow. Specifically:
    1: Using scroll window drops my framerate from 60fps to 17fps (when scrolling)
    2: Opening my backpack and enabling part of my UI causes about a 0.5s "freeze" even though the UI has already been generated and was just disabled/enabled.
    3: When first loading my character and creating the UI (I use a script) it takes about 10ms for each GUI square button. Since I have 1000 squares (in the talent trees) it causes about a 10 second "freeze" when loading the game.
    4: Hovering over a button (tinting it) causes a frame rate drop.

    I have a new gaming computer (SSD w/ GeForce 1070).

    You can see my UI in this video.


    Has anybody else struggled with a slow UI. Any tricks or things to improve this? Thanks.
     
    Last edited: Feb 28, 2019
  2. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    Regarding issue #2. Solved: Disabling/enabling the canvas instead of disabling/enabling the GameObect makes it much faster (presumably disabling/enabling the canvas doesn't clear the cache but disabling/enabling the GameObject does... or something like that?)

    Regarding Issue #1: It appears that things outside the scroll mask slow the frame rate even though they aren't rendered. For example if your scroll mask can only show 5 things at a time having a list with 20 things (5 shown 15 masked) is much faster than a list with 100 things (5 shown 95 masked). Seems like poor coding of the scroll mask. Unsure how to fix.

    Regarding Issue #4.
    https://unity3d.com/learn/tutorials/topics/best-practices/fill-rate-canvases-and-input
    "Important reminder: Whenever any drawable UI element on a given Canvas changes, the Canvas must re-run the batch building process.This process re-analyzes every drawable UI element on the Canvas, regardless of whether it has changed or not. "

    Turns out my Unity UI is constantly redrawing things that haven't changed and that is why it is slow. If my button is on the same canvas as other things then when I hover the button (tinting it) then it redraws everything else (even though those other things haven't changed)..

    With some work (i.e. splitting the UI into many canvases and other things) I can make the UI faster. But this puts a lot of burden on the developer to properly configure the UI for optimum performance.

    But even if everything in my UI was redrawn from scratch every frame I do not understand why rendering the 2D UI is slower than rendering a 3D world. It would seem to be that a 3D world with 100,000's of tri's and 3D lighting, normal maps, spec maps, 3D perspective, etc. would take a lot more to process than a 2D UI. But for some reason the 2D UI is killing my framerate. Something seems wrong.
     
  3. zhuxianzhi

    zhuxianzhi

    Joined:
    Mar 30, 2015
    Posts:
    122
    fbonetti and Zullar like this.
  4. silvergat

    silvergat

    Joined:
    Jun 11, 2020
    Posts:
    22
    same problem with me i tried everything but it solves nothing
     
    georgetowersassets likes this.
  5. vejab

    vejab

    Joined:
    Dec 21, 2021
    Posts:
    119
    Maybe this can help :