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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity UI Best ways to keep my Canvas between scenes?

Discussion in 'UGUI & TextMesh Pro' started by Marscaleb, Sep 16, 2023.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,005
    This is only my second project where I'm using Unity's UI system; I used to use the IMGUI well past its expiration date so I could control my UI through code.

    I'm trying to figure out how I should handle keeping a uniform UI across different scenes, since now my UI and HUD are built on a canvas that exists as part of my scene. I can build a nice HUD in one scene, but how do I have that same HUD in the next scene?

    In my last project I kept the HUD in a separate scene with my player's gameobject, and used scene manager to load/unload all my scenes.
    This worked for that project because streaming in multiple scenes worked for that project; I was bringing in a lot of smaller elements to make as ingle larger "world" in my game.

    But I don't want to do that for my current project; given the scope of my levels for this project it would be too much of a hassle to set up multiple scenes in the editor. Unlike my last project I'm only working with one scene at a time, so I don't want to have to track multiple open scenes in the editor. I want a way to consistently get the same UI for each scene individually.

    I suppose I could try making the entire canvas a prefab, but something about that is setting off warning bells in my mind. I don't actually see something wrong with doing that, but it sounds wrong.

    Also, how can I automatically set up all the connections? The HUD needs to know the values it is displaying; I'm wondering if there are any good ways to get my scripts to be able to find those elements without me having to plug them all manually in the editor.