Unity displays 3D objects in front of the UI (nanny level is super easy)

Place 3D objects on the UI interface

After reading some tutorials on the Internet, this article is a slight simplification based on the previous ones.
To sum up, in fact, only need:

  1. add a camera
  2. Add a Render Texture
  3. Add a Raw Image

Next are the detailed steps

First of all, we create a new project like this:
Create a new canvas and insert the background.

At this time, we cannot see the 3D image. Add a camera near the image, click the "2D" button on the upper right to switch to 3D, as shown in the figure
: Put a 3D object in front of the camera, here I put a capsule:

create a render Texture in the project interface:

mount the Render Texture to the new camera:
create a new Raw Image on the UI, adjust the size arbitrarily:

set the Render Texture Mount the Texture on the Raw Image:

This is done, because it is too dark, I added a parallel light.
If it is a 3D project, the background may still be displayed at this time. Just change the Clear Flags of the camera to Don't Clear. :

You're done!

Guess you like

Origin blog.csdn.net/weixin_44099953/article/details/127492974