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

Developer Console, default GUI kills performance

Discussion in 'Immediate Mode GUI (IMGUI)' started by Morning, Aug 20, 2013.

  1. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    Hello,

    I am making a developer console, the backend is going well, the frontend not so much.

    The window:

    $consol.png

    It works fine BUT performance is dreadful. Every entry is a separate TextArea for these reasons:
    1. Text needs to be selectable
    2. Every entry needs to be able to support custom color

    In empty scene when console is closed 0.3ms, when open 4.8ms idle and up to 8ms while scrolling the list. Drawcall amount is rather small, ranging between 45-47, not perfect but bearable.
    I also tried combining everything into one TextArea but the performance was still terrible.


    If I reduce the amount of items in log(currently max is 500) performance increases obviously but that defeats the purpose of log if you can't read back.

    I thought of using NGUI but text there cannot be selected.

    What to do?

    Thanks a lot for support.
     
    Last edited: Aug 20, 2013
  2. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    You have the following options (and you can combine both for better performance):

    1. Render only the selected TextField as TextField, and render others as labels (using the same GUIStyle - users won't tell the difference).

    2. Virtualization: this is a huge topic but basically you have to render only the visible rows. So, instead of total 100.000 rows you are displaying only 10 visible rows.

    Not an easy task, but there is an easy way of doing this (sort of): make 10 static rows and change their values when scrolling. It won't be perfect (the scroll step will be equal to a row height) but would work perfectly.

    This - of course - means that you got to have control over the scrollbar (its size and position), so you should not use GUI.BeginScrollView, but GUI.VerticalScrollbar instead.