"Komatsu teaches you to develop", "Unity practical Skills" U3D level issues Summary

Source: Internet
Author: User

First of all, the Ngui distinguishes between the pre-and post-hierarchy relationships with depth values. Has nothing to do with Z-axis values   first because I use Ngui, so my u3d level problem is Ngui hierarchy problem   First determine the UI rendering order, Camera>uipanel>depth (uiwidget) here means , first determine the relationship between the different chunks of the camera's depth value, according to the size of depth, this determines the front and back relationship of each chunk. Then, according to the UIPanel depth, this is used for each chunk within a plurality of uipanel may be divided into small pieces, each small block between the front and back relationship. Finally, the depth values of uiwidget (such as Uilabel,uisprite, which are inherited from Uiwidget), are determined in relation to the same uipanel.    here is a summary of two aspects of the problem: 1. The overall level of the 2.UIPanel level     one, the overall level: the overall level refers to a game UI is generally divided into several modules, such as effect (special effects), Background, Main, Popup and so on. Between these chunks to differentiate between pre-and post-relationship (such as background finally, main in the middle, popup first) to distinguish between the pre-and post-hierarchical relationship. These levels generally have the same parent node ui_root (not in the same parent node)   Basically the overall level is based on the layer to sub-relationship, layer itself is not with depth, so in these chunks, They usually have a sub-node camera in their gameobj itself or below them. Use the camera's cullingmask to determine what layer the camera is specifically rendering. The depth value of this camera is adopted to determine the relationship between the whole hierarchy.   NOTE: The z-axis value affects the relationship between the large camera if the depth value is the same. But this should be avoided. Should not have the same depth is worth the difference between camera    and uipanel levels   There are many analyses of the relationship between the different z-axis values in various atlas (map sets) and different depth. But if you know why you can handle all the situations. Explain here.   How does the hierarchical relationship form? is because of the pre-and post-relationship of the rendering order, the more late the rendering of the more in front, all by dividing a scene into a few pieces, the order of the rendering sequence, in order to render the interface will be able to display normal without causing occlusion confusion, so that can controlThe hierarchical relationship of the UI is well-made. And UIPanel's role is to determine what to put together to render and uipanel depth is to determine the rendering order of each block, and finally generate a drawcall. So the first thing to solve is to render something to a piece, that is, a drawcall inside what to render, a uipanel to include what.   An example:

Like this interface can be divided into several pieces:

Each piece can be divided into a uipanel, each UIPanel control its own depth and transparency. Can handle the occlusion between the problems. These are the basic rendering logic of Ngui, but Ngui will automatically render the same set of images in the same interface, that is, whether you have a few uipanel,uipanel depth 3,4,5, or 30,40,50, as long as the same atlas will be rendered together. Then the relationship is calculated by the addition calculation.  But here's the problem, if you have two atlas, the depth of the pictures of the two atlas intersect each other, which causes Ngui to fail to recognize the same atlas, resulting in rendering errors, resulting in more drawcall. Example: If the depth of two sprites in the same atlas are different such as 1,3. There is another atlas (such as a font) in the same panel with depth among them, such as 2. Atlas1_sprite:depth 1
Font_label:depth 2atlas1_sprite:depth 3 This is not two drawcalls is three this is why in different situations depth can not control the rendering order. So here the general project will have a relatively trickery method to avoid. 1.UI uses only one Atlas, 2. The depth of the font is placed above 300. Then after completing a uipanel need to check, Drawcall is normal. This can be viewed by opening the Drawcall tool in Ngui tools. (The goal is to merge the same Atlas Drawcall into one) after the UIPanel problem will be solved by UIPanel and uiwidget depth

"Komatsu teaches you to develop", "Unity practical Skills" U3D level issues Summary

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.