Search Unity

CanvasRenderer Bug? Canvas Disabled at prefab vs Disabling it at Start()

Discussion in 'UGUI & TextMesh Pro' started by shivansps, Sep 18, 2015.

  1. shivansps

    shivansps

    Joined:
    Feb 26, 2014
    Posts:
    60
    So this is the issue, my gameobjects have a worldspace canvas and a screen space canvas attached to them, and a script that enables/disables them on demand. By default, that script sets both canvas gameobjects to false at start(), so no unit UI will show up as default.

    But i was starting to notice that, for example my fighters after they are created, the Canvas renderer was starting to use a lot of CPU altrought the canvas gameobject was inmidiately set to false. I trought, wait thats odd, the canvas IS disabled and working as intended, why this "CanvasRanderer.OnTransformChanged()" is taking any CPU time?

    Then what i did was to disable it directly at the prefab, CanvasRanderer.OnTransformChanged() stopped using CPU time for a huge performance boost.

    Canvas disabled at prefab


    Canvas enabled at prefab and disabled by script at Start()


    Also i have no idea of why "CanvasRanderer.OnTransformChanged()" is listed under "FighterAI.Update()", that script is not related to the canvas in any way.