NGUI 2DCamera and 3DCamera co-exist solutions

Source: Internet
Author: User

The main problem is that the panel contains a 3D model, and if there are only 1 orthogonal cameras, the display quality of the 3D model will be poor. If you use a perspective camera only, the UI will deform

The official example of Ngui is to use 2 UI Root and create a camera to render the model to the patch. But it's a bit complicated, and it's too expensive for a mobile platform, and it's not for a panel. A prefab form

Testing for a while, now my personal better solution is to use only one UI Root,uiroot level with 2 camera,camera2d and Camera3d. The 3D camera has a lower rendering depth than a 2D camera.

The rendered object is marked with a ngui,ngui3d two layer respectively.

The 3D model can then be assigned to the Ngui 3D layer, the Ngui component or the Ngui layer. You can implement basic 2d,3d mixed rendering, but this only supports 3D objects that are not Ngui components

I simply marked the following:

UI Root

|-camera2d (Uicamera)

|-camera3d (Uicamera)

+-uiwidgets

+-widget1 (UIPanel, Layer:ngui)

|-mysprite1 (Uisprite, Layer:ngui)

|-my3dmodel (layer:ngui3d)

|-widget2 (UIPanel)

If you need a 3D UI, you can give it all to the 3D layer

Ngui There is a problem, for UI sprite,ui texture These basic components, a UI panel node is allowed only one layer , that is, all Ngui or Ngui 3D layer object. If given 2 different kinds will be automatically repaired.

So the 3D sprite and 2D sprite want to coexist, if the implementation must be placed under different panel. The need to change the hierarchy, it will be very troublesome, like this:

UI Root

|-camera2d (Uicamera)

|-camera3d (Uicamera)

|-uiwidgets (Transform, Layer:default)

+-widget1 (UIPanel, Layer:default)

+-2dcontentpanel (UIPanel, Layer:ngui)

|-sprite1 (Uisprite,layer:ngui)

|-sprite2 (Uisprite,layer:ngui)

|-sprite3 (Uisprite,layer:ngui)

+-3dcontentpanel (UIPanel, layer:ngui3d)

|-sprite1 (uisprite,layer:ngui3d)

|-sprite2 (uisprite,layer:ngui3d)

|-sprite3 (uisprite,layer:ngui3d)

But the need for less, such as a large background behind the panel, this time lazy to use quad patch to replace, or create a Ngui3d UI panel to put Uisprite in, and prevent panel penetration of the bezel still exist in the 2D UI, so that does not affect the cascade use

Also tested, the uipanel nesting is equally effective, is the Ngui layer of the Panel nested Ngui 3D panel

This approach also has no problem with cascading UI. A 3D model is a pure display that does not participate in the reception of any UI events.

NGUI 2DCamera and 3DCamera co-exist solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.