Unity UGUI and model mixed display (ui display special effects)

Off-topic: I have always wanted to write something, but I always have some fragmentary knowledge, and I can’t make an article. There is a kind of blog that is someone else’s blog, so I still have to study hard.

Foreword: When working on a project, I will encounter mixed layout of the model and UI. When I used ngui before, I remembered that it was possible to put the model directly in it, but sometimes it won’t work if Ichange the ugui. I will show you the following , I use Unity5.5, I will use two methods to achieve below.

The first method: This is the method in the official Ugui demo, which is to use the camera to create a Render Texture to achieve mixing

1: First, right-click on create Render Texture in your project view

2: Then create a new camera and aim at your model

3: Give the camera target texuure a Render Texture

At this point you can check your render texture to see if it is clear, if it does not meet your requirements, you can modify the render texture

4: Create a new Raw Image under your canvas, adjust the size, and then drag the render texture into the texture.

ps: Here we can modify the culling mask of the camera so that the camera is only valid for the model. For example, I set the model level as model here.

Then selecting the camera will only advance this levelRow rendering

The final rendering:


The second method: The second method is actually similar to ngui. We know that there is a UICamera in the UI to render the ui in ngui, so...

1: First, we create two canvases, one is BgCancas for background images, and the other is UICanvas for UI, and then set the rendering mode of the two canvases to camera rendering

For BgCanvas our Plane Distance, we can use a larger setting, and then we can set a smaller UIcanvas. It’s ok if it meets your requirements.

2: Then adjust the position of your model and finally present the following effects

Finally it can be achieved

ps: If you are the same as me, for BgCanvas, we don’t need any interaction, then we can remove Graphic raycaster to save performance

Well, the two modes are introduced here. Let me tell you about it. In future projects, you can use multiple canvases for hierarchical rendering (up to 3), and then create a special UICamera to render the UI. You can use the UIcamera The rendering mode is set to orthogonal mode (perspective mode is said to be blurred for Jiugongge pictures, specifically I have not encountered it), and then set the culling mask of the ui camera to the UI layer, that is, only the UI is rendered. So if this is the case, your particle effects, drag mark effects, etc. can all be presented on the UI ! ! ! Multiple cameras recommended

Guess you like

Origin blog.csdn.net/K20132014/article/details/78117344