Search Unity

Unity UI 5.6 Nested Canvas Not inheriting Screenspace property

Discussion in 'UGUI & TextMesh Pro' started by BTables, May 3, 2017.

  1. BTables

    BTables

    Joined:
    Jan 18, 2014
    Posts:
    61
    Just upgraded to 5.6, we use a lot of nested canvas objects for performance.

    All our canvases render in screen space overlay mode, and for some reason only UI elements that belong to the root canvas are rendering in screen space, all children of the nested canvases are rendering in world space mode and there is no setting on the nested canvas to change this.

    These canvases are added from code after the ui components are built, this may contribute to the issue.

    I tried setting the render mode from code after their creation, which works to get them into screen space rendering, however they don't seem to be anchoring relative to their parents correctly and anchor to fullscreen like they are an independant canvas.

    Has anyone else found a solution to this problem?
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Not sure why you are using Nested Canvases. In my experience, the only reason to use multiple canvases is if you want to change the render mode of a canvas.
    If you only need multiple panels within a Canvas, then use Empty GO's and enable / disable them acordingly. The UI Sample on the Asset store has a good example of this.

    However, what you describe is likely a bug and I'd report it through the Unity Bug reporter in the editor.
     
  3. BTables

    BTables

    Joined:
    Jan 18, 2014
    Posts:
    61
    We initially did this for performance as in our very complex UI hierarchies the OnWillRenderCanvas was taking far too long on simple transform changes to UI elements.

    We separated the canvas in an attempt to partition what needs to be redrawn on change. One of my other dev's worked on this so I can't vouch for if it did achieve the desired performance increase.
     
  4. guzzo

    guzzo

    Joined:
    Feb 20, 2014
    Posts:
    79
    As far as i know, if you keep all your UI objects in a single Canvas, as soon as the canvas is marked as dirty by any of them, it must be rebuilt completely. If you split the UI in more than one Canvas, you can avoid rebuilding static UI objects. However, you cant batch together objects within different canvases so it is not always convenient to split canvases. It depends on the UI and the project.