Search Unity

Unity UI Drawback of whole game on Canvas?

Discussion in 'UGUI & TextMesh Pro' started by indie6, Jul 24, 2018.

  1. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Hello everyone

    I am in the initial phase of making a grid based puzzle game and have to decide whether to go with making the whole game in Unity Canvas or use the 2D sprite approach. On an abstract level it will have dragging functionality like this




    My main requirement is that the game runs with a smooth FPS and is easily adjustable on various screen sizes. Unity UI is really good at the 2nd part i.e easily adjustable, but I am a little concerned about the FPS as according to my findings, doing operations on UI items within canvas is expensive, like manipulating a rect transform, changing an image, the whole canvas redraws again and the canvas mesh recreates. Since my game will also involve simple animations, using layouts, excess of mouse dragging, will this have any effect on performance?

    I would really like to get some feedback from people who have already been through this stage. Thanks a lot.
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Seems fine. Separate content into panels based on frequency of change as a single element in a panel will dirty that panel for rebuild.

    Don't add a raycast thing to each element, only that which you need to interact with.

    Look up UI optimisations, of which there are many in the Learn section and, well everywhere I guess.

    Otherwise while it's not the slowest or fastest, it's certainly fine for what you're doing and probably wouldn't matter either way.
     
  3. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    338
    The number one question when considering FPS, what platform are you developing it for?
    If mobile, depending on the number of objects and animations, you might have to let go of the comfort of developing it using canvas and might have to work with scene sprites instead.
    But if you choose to use canvas, to optimize FPS try to split your hierarchy into different canvases as this is usually a performance bottleneck for big scenes.