How to handle UI/Space mixed scene?

Hi everyone!

I’m having these interrogations about my main scene setup.

  1. My whole scene that you can see below is fully UI/Canvas-driven so it can adapt to different screen resolutions.
  2. I need the background to take the whole screen.
  3. I have a character that will live and behave in the center part, i want the UI to act like walls on bottom/top and sides. He has physics and rigidbody2D.
  4. He is imported as a unity prefab from spriterPro, by default rendered with SpriteRenderer and Animator. So i don’t know if changing him into UI will not break all of his animations. He now appears behind the background (because it is UI and renderer on top)

What would be the best method to have my character rendered before the background, behind all the other parts while keeping his all his physics properties? (His pathfinding is also world-space driven)

Thanks you!

I recently tried to do something similar and in my opinion you shouldn’t try to use UI for 2D graphics, they are very different things.

What I’m saying is that the background, your character, everything that is the game world should be 2D sprite based, and only the buttons should be UI (it is just logical if you think about it).

Of course with this you get the problem of different screen sizes, but because you have some nice objects that are borders to your scene you can just cover up different amounts of the screen with that.

Hope this helps! Feel free to ask if something isn’t clear!

Btw, I like the style of your game!

Thanks for the reply.
Yeah i understand your point but resizing is really working smoothly with this setup for the surrounding elements. Plus it’s acutally UI/world scene mixed element since they will have buttons and interactible elements on it while acting as world scene borders.

There was a Unity option made for this actually, which is the render mode Screen Space - Camera in the canvas. It seems to do exaclty what i wanted, spatialize the UI elements in world space/camera space while keeping its UI rendering and resizing properties.
I just had to add colliders on my borders after that and there it was, working!
I’ll make the background and character sprites and handle their resizing via scripts.

Thank you, appreciate it! Have a nice day!