Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity UI Make a Canvas for each level or make a single canvas for all levels?

Discussion in 'UGUI & TextMesh Pro' started by hasanbayat, Aug 22, 2017.

  1. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    626
    Hi.

    I am confused in making UI for my game.

    Do i make a canvas in every level or make a single canvas and make it dontdestroyonload?

    While the UI is same on levels, why don't make a single UI canvas and make it dontdestroyonload?

    Also the single UI canvas make it easy to change ui objects.

    But unity example projects such as Tanks!!! Reference Project using canvas per level.

    Any help is appreciated.

    Thanks.
     
  2. Terko

    Terko

    Joined:
    Apr 20, 2013
    Posts:
    32
    It's a good idea to keep a balance between number of canvases and number of objects! When you change something inside a specific canvas it will get completely rebuild! (each gameobject).
    You can check out the asset called Woo Panels. It solves the problem of panel switching and navigation between menus! Will save you tons of time when creating UI. Also you can learn something from it. Here is the forum thread.
     
  3. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    626
    Thanks for sharing answer.

    My question was Which one is better create a canvas by each level or create a single canvas at start scene and make it dontdestroyonload?

    the Woo Panels does the Panel Management and i don't have problem about that, my problem is how to manage canvases.
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    If you have a lot of different graphics for different scenes it does not make a lot of scene to have all the sprites loaded in all scenes.
    If you can reuse a lot of pats of the canvas then it makes sense.
     
  5. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    626
    I have same graphics for all canvases in all levels, but it is different from the main menu, shop and some other.