How to place object on top of ui?

I’m trying to place a 3D object on top of a UI Image

But nothing works. Can anyone give an example of how to add a 3d model on top of a UI Image in a 2d game.

The strange thing is that I have all the objects closer to me in the Z- coordinate.



Another oddity is that Sprite objects ignore hierarchy. They are always above the UI Image and the only thing they react to is Additional Settings

Why does the hierarchy not work for me?
Can anyone explain what I’m doing wrong?
Where is the mistake?

Three (3) ways that Unity draws / stacks / sorts / layers / overlays stuff:

https://discussions.unity.com/t/841904/2

In short,

  1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

  2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

  3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

  • identify what you are using
  • search online for the combination of things you are doing and how to to achieve what you want.

There may be more than one solution to try.

Additional reading in the official docs:

https://docs.unity3d.com/Manual/2DSorting.html

1 Like

Well, I realized that these are different types of objects. But I want to do all of them UI. But the only thing I found was to simply translate the 3D object into PNG and connect it to the image. But I have a custom object with several animations and a texture and it doesn’t work for me. Someone says just change canvas to world space. But it doesn’t change anything for me at all.

That certainly would work. Move it behind the 3D object and it will be behind.

I have a similar problem. I have a worldSpace canvas with an image on it behind a 3D object, but it appears in front of the object, unless that object is very close to the camera. In other words, the camera seems to think the canvas is closer than it actually is. What is even stranger is that I have a similar canvas with the same image and material next to it, and it works just fine. Also, the problem only happens in the game view. The scene view is rendered exactly as I want.

After playing around a bit, I’ve realized that when I do right click > UI > Image outside a canvas, a canvas object is created automatically before creating the image inside the canvas, but this problem arises. But if I first create the canvas, then create the image in the canvas, it works correctly.