Ugui Canvas Layout Hierarchy relationship (i)

Source: Internet
Author: User
Tags touch

One, the people who have used Ngui know that there can be dept between various Ngui sprites to manage the hierarchy, and in the Ugui of unity4.6 beginning, this is to set the depth relationship through the canvas.

I have designed three canvases in development to handle different types of UI messages

Staticcanvas

Touchormousecanvas

Buttoncanvas

1, Staticcanvas, the sort order I set to 0, I used to deal with some not to touch the screen and buttons (here is for mobile phones) corresponding UI placement, such as the role of blood, magic value, injury of blood Hudtxt, enemy head of the blood volume tips

2, Touchormousecanvas, the sort order I set to 1, is for the touch screen response message and set separately, such as through the touch screen to change the camera rotation, in the Touchormousecanvas directory to add a panel, In addition to an event Triger component, set its enent type to drag, and give it a specific message response function skill to implement the touch screen control camera rotation.


3, Buttoncanvas, its sort order I set to 2, is to handle the various button message response, the various buttons of the UI are placed in this

Attention:

The canvas's render mode must be the same, and its sort order will work. As shown in the figure below



Ugui components In addition to the canvas is no Inspector hierarchy concept, the components under the same root directory is determined by the hierarchy relationship under the root directory, who is under the game and scene view, who will obscure who.



Iii. Additional considerations when setting up a camera to render the layer layer of the UI separately

Camera settings as shown below


Then the canvas's render mode is set to screen Space-camera

Drag and drop your set camera into the render camera

And the layer of the canvas must be the same as the culling mask of the camera you set up, otherwise you will not see it in the game field.

Plane distance to be larger than 1 (0 to 1 is OK, but you have to adjust it to see it in the game view), otherwise the game view is not visible

The above figure UI camera culling mask is uilayer layer

The following is a corresponding canvas screenshot


After adding multiple cameras to the Unity project, the following warning appears: There is 2 audio listeners in the scene.   Please ensure there are always exactly one audio listener in the scene. Workaround: Remove the audio listener after adding the camera

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.