Need help putting a UI button on top of sprite.

I wana make UI button and UI image on top of 2d sprite.
But no matter what layer i select or sorting layer i use UI always seems to appear behind sprite.
Anyway to make it appaer in front of it.

It should be doable if you set your sorting layers properly. I have UI on top of sprites in my MiniScript demo, for example. I have my sprites in the Default layer, and my UI Canvas set to use Screen Space - Camera, sorting layer Default, Order in Layer 0. Importantly, the Plane Distance is set to 10, which is also the distance from my camera to the Z=0 plane. If I set the canvas’s Plane Distance to more than 10, then it pops behind the sprites (which are at Z=0).

(I also have a second canvas for the background, which is also using Screen Space - Camera at a plane distance of 10, but I set its Sorting Layer to Background, so it appears behind everything.)

But UI elements dont have any sorting layer, so how can you layer that??

Canvas has a sorting layer.

5 Likes

wow dude you posted that 5 years after you joined