Search Unity

Performance Issues when canvas (with child) is attached to main camera

Discussion in 'UGUI & TextMesh Pro' started by Skeketor23, Aug 2, 2019.

  1. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    49
    I've seen a huge performance impact, when I attach a canvas which has a child (text, panel, image) to the main camera.

    Profiler shows this all the time:
    upload_2019-8-2_23-7-9.png

    This was done in a simple empty (VR) application with unity 2018.4.3f1.
    upload_2019-8-2_23-9-54.png


    When I remove the image from the canvas, I get a huge performance boost and the Canvas.BuildBatch-calls are gone.
    I wanted to use the image as a crosshair as showed in many tutorials. But with such a big performance hit, it does not make sense.

    Any way to optimize this? Why all the calls permanently? The canvas is not changed at all, just the position is updated? Or am I missing something?
     

    Attached Files:

    Covfefeh likes this.
  2. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    49
    Update: It's the same in unity 2019.2.
    You can see in profiler what happens, once the image is switched on:

    upload_2019-8-2_23-35-26.png
     
  3. Skeketor23

    Skeketor23

    Joined:
    Apr 6, 2019
    Posts:
    49
    And another update. It seems only an issue with VR. When I disable VR and just move the camera in the game, I don't see this stuff in profiler and don't see the performance impact when adding the image:
    upload_2019-8-2_23-47-4.png
     
  4. Covfefeh

    Covfefeh

    Joined:
    Jan 14, 2018
    Posts:
    6
    I'm in the exact same situation here. The Unity VR Samples uses this method (canvas is child of main cam).
     
  5. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    If your case is really just a cross hair, don't use a canvas, just use a simple sprite renderer parented to your camera rig.
     
  6. HypergolicGames

    HypergolicGames

    Joined:
    Aug 3, 2016
    Posts:
    2
  7. lauhonyeung

    lauhonyeung

    Joined:
    Apr 29, 2017
    Posts:
    30
    ugui sucks, I can easily write a ui system better than unity
    I decide to use quad&textmesh instead of ugui