How to keep UI overlay across multiple canvases in a scene?

Hi,

how can I build a UI that persists across multiple canvases? That is if I change to another canvas on the scene, the UI remains.

What you’re asking doesn’t really make sense to me. If you have some UI that should “persist” as other canvases change, then just place that stuff is its own canvas. You can have multiple active canvases at the same time, with the Sort Order controlling which one is on top.

2 Likes

So how would I approach this then? I’ve got two canvases, each has a button that changes the canvas, but I lose the elements when I swap canvases.

How can I make UI elements that persist?

This could mean lots of different things. What specifically is that button doing?

You need buttons inside one Canvas which activate or deactivate other Canvases.

Are you using the “highest” type of UI layer? That is, the overlay mode? This one sort of lives in its own domain and is last displayed so as to behave like a HUD. You might want to try components that allow you to order things according to layers.
It sounds like you want elements from canvas #1 to be transferred to canvas #2, perhaps, I guess, with a drag and drop menu. Maybe you’re doing a RPG inventory and you display a popup that contains items and you’d like to drag them into the main inventory “window”? This could be done within a single canvas anyway.
Otherwise, you can try reparenting game objects.

Sorry - What I am trying to achieve is -

basically a simple clicker game, that has the main screen with the clicker stuff and then another scene (canvas?) which is like a buy menu.

All of these screens would have would have a left hand navigation, similar to this -

I want to be able to reuse those components no matter which screen is selected, but not unload or lose action in the main screen/canvas when in the second screen.

How would I go about having multiple scenes/canvas that have an overlay that isn’t lost when changing between the two of them? I don’t want all elements transferred just the “menu” elements, effectively.

Basically - how would I go about trying to do this -

You can keep your UI as separate scene, which is on the top.
Then load / unload your game level scenes.

1 Like

So would that be two different scene objects? Is there any documentaiton or video on how this could be done, or someone able to show me an example?

Load your scene in additive mode and keep an eye on deletion if unloaded too.

Would deleting/onloading cause the actions in that scene to stop? For instance - if clicking and going gold per second, I’d want thtat to continue.

Will not, if you design scene management righ.
Mind, you can have more than active scene.
One for UI, one for core mechanics another one scene1 etc.

Can you please link me an example or appropriate documentation for this?

There’s lots of topics being discussed now, so no idea what you mean by “this” here. But if you are asking for how to additive load a scene, the below documentation seems simple enough to demonstrate the difference.

https://docs.unity3d.com/ScriptReference/SceneManagement.LoadSceneMode.Additive.html