http://blog.csdn.net/meegomeego/article/details/42060389
Recently encountered several drawing images of the relationship between the occlusion of the problem is not correct, the information found on the web is more messy, so here to solve their own problems summarized in the experience recorded.
The rendering order in unity is broadly divided into three layers from top to bottom. The top layer is the camera layer, can be set in the camera's depth, after setting, the graphics rendering order is to first draw the object under the depth low camera, and then draw the object under the camera of depth high, that is to say, Depth high camera will cover depth low camera (specific coverage relationship with Don ' t clear, solid color, etc.)
A little lower than the camera layer is the sorting layer, you can find a place to set sorting layer, select sorting layer, click the Add button, you can see all the current sorting layer, and can change sorting layer, the sorting layer behind the row will overwrite the sorting layer on the top of the row. After setting the sorting layer relationship, you can set the sorting layer for any object that inherits from the renderer class, or has a renderer subclass as field. Note that the occlusion of these sorting layer is at the same camera level. The renderer rendering order under different camera is subject to the depth of the camera. Some component sorting layer can be set directly in Unity Editor, such as Sprite Renderer. Some of them need to be set up in code, such as setting the sorting layer of the particle system, and need to take ParticleSystem.Renderer.SortingLayer in the code to set it up.
A layer lower than sorting is the sorting order, this number refers to the same sorting layer under the rendering order, the usage is obviously not to repeat.
Be careful not to confuse the gameobject layer, and the renderer sorting layer. Gameobject Layer Personal Understanding is a logical layering, used for camera culling mask and so on. The renderer sorting layer is used for rendering. The sorting layer is only required for component that inherit from renderer or have renderer as filed.
It is also necessary to point out that the common Ngui widget depth Its essence is also a sorting layer under the sorting order. Ngui seems to be using a sorting layer called "UI". Therefore, if you need, you can also take hack Ngui code, Ngui sorting layer exposed for their own customization.
In a nutshell, the hierarchical order in which unity rendering relationships are determined is:
Camera
Sorting layer
Sorting order
Unity Rendering Hierarchy Relationship Summary