Search Unity

Question Do I need multiple canvas?

Discussion in 'UGUI & TextMesh Pro' started by lz7cjc, Sep 8, 2022.

  1. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    541
    Hi
    I am using 2019.4.31f1 and hacking my way through this so apologies if this is a stupid question.
    In my rather large scene I have 20+ canvas for my UI, which basically contains text and some panels and images. Text is a mix of simple text and TMP (once I discovered this). The UI is spread around my world in distinct locations

    The scene is pretty large and I am looking for ways to improve performance and reduce size. Can I remove all of these canvas and just have one? Will it make much difference to performance/size? Or am I better off leaving it alone and trying to sort out textures which take up 85% of the 600mb+ build size?

    thanks for your advice
    Nick
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    No it will probably not improve the performance and won't have any noticeable difference on build size. There are even situations where having everything in single canvas will make the performance worse, but don't go blindly splitting everything into more canvases if you don't understand how it works, so better don't touch that for now.

    As with any optimizations (build size and performance) don't randomly guess. Use the available tools to measure what exactly causes the biggest performance issues and focus on improving that.

    For build size there should be a report telling what is consuming the space. Read this https://docs.unity3d.com/Manual/ReducingFilesize.html . If you already know that textures take 85% of space why would you even think about reducing size of anything else. One more suggestion not listed there is that you can use sprite atlas feature to pack sprites more compactly. Depends on the style of game you have, you can get the most benefits of this if you have 2D game with bunch of nonrectangular sprites.

    As for the performance start with unity builtin profiler https://docs.unity3d.com/Manual/Profiler.html .
     
  3. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    541
    thanks - really helpful. I do have the log in report plugin which is where I get the 85% figure from
    reason I am not looking at textures is that I don't know where to start! It is a VR 3d simulation and am using graphics built for mobile but it seems that might be a little optmistic.

    If you know any idiots guides to textures I would love to try to learn
    thanks
     
  4. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    Think about it. Even if you reduce everything else to 0% (which is very unlikely) you wouldn't get more than 15% improvement.


    All you need to know is in the first link I gave under "Textures" section. There isn't much more than reduce size/increase compression setting until it starts looking bad. Repeat for each texture. See the instructions in link for how to do it within Unity so that you don't have to modify original assets and easily switch back and forth between different sizes and settings. Also be aware that texture compression during build and image compression for image files you import (that is whether they are saved as bmp, png, jpg, and with how much compression) are two completely different things. Cranking up the jpg compression before importing into unity will not improve the build size. For more information about texture import settings read https://docs.unity3d.com/Manual/class-TextureImporter.html
     
    lz7cjc likes this.
  5. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    541
    Thanks very much for your help