Unity3d Setting the 3D model to appear before the 2D background (multiple cameras layered) (RPM)

Source: Internet
Author: User

Steps to resolve:

1. Add a camera, name Backgroundcamera, and add a background layer on the layer. and drag and drop the plane under the camera node. Then Backgroundcamera and plane are placed on the background layer, modify clearflags not depthonly depth rendering, and set Cullingmask to see only the background layer, and set depth to 1 , indicating that the background layer is the deepest, the other model is located in the camera's depth is the 0,ngui is 1, here the hierarchy relationship is Ngui in the front, the model layer second, then the background layer, so make sure 3D model in front of the background!

2. The same operation, the Maincamera set, note that the Maincamera Cullingmask can not contain the background layer, that is, so that it does not see the background layer, or there will be a background to mask the situation of the model.

3. Add a script on plane to dynamically load the map on plane

View Sourceprint? 01. using UnityEngine; 02. using System.Collections; 03. using System.Collections.Generic; 04.  05. public class AddBackground : MonoBehaviour 06. { 07. public Texture2D mtexture; 08.  09. void Awake() 10. { 11. //        Texture2D mtxture = new Texture2D(Screen.width, Screen.height); 12. //        renderer.material.mainTexture = mtxture; 13. //        mtxture.Apply(); 14.  15. gameObject.AddComponent<guitexture>(); 16. } 17.  18. // Use this for initialization 19. void Start() 20. { 21. guiTexture.texture = mtexture; 22. transform.localScale = new Vector3( 0 , 0 , 0 ); 23. transform.localPosition = new Vector3( 0 , 0 , 25 ); 24. guiTexture.pixelInset = new Rect( 65 , 0 , Screen.width, Screen.height); 25. } 26. }</guitexture>

The z-axis property of the Start method above is set to the original attempt, and the depth modification by z-axis is not position, or the layer relationship affects the depth of rendering.

4.

Unity3d Setting the 3D model to appear before the 2D background (multiple cameras layered) (RPM)

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.