I am new to Game Development and using NGUI plugin free version. There are few sprite images in my game. I made them prefab and instantiated at runtime. then I created NGUI Texture and Made it background. When I play my game. sprite prefabs instantiate behind the NGUI Texture Background. I want to place them front of NGUI Texture.I also changed camera Setting, now mainCamera depth is -1, and NGUI Camera depth is 1. changed both of them. But, could n't find solution. I have tried in several ways.

Any suggestions will be highly appreciated. Thanks


There are a few values that are crucial to multi-camera rendering in Unity: the culling mask, the clear flags, and the depth value. All three are mentioned in the camera component manual.

mainCamera depth is -1, and NGUI Camera depth is 1.

Unity draws cameras in ascending order. If you want the NGUI background behind the scene, you should flip those depth values.

You should probably also make sure that the two cameras have appropriate culling masks. In this case, that might mean the UI camera should render only the UI layer, with the main camera rendering only other layers.

I'm not sure if NGUI renders to the depth buffer, but most multi-cam configurations call for clearing depth between cameras.

  • \$\begingroup\$ Thanks for your time. but i have tried changing mainCamera depth and NGUI camera depth but it's not working. I have applied NGUI Texture as a full screen background. my sprites is instantiating at runtime behind the NGUI Texture background. I have also tried to create another UI Camera. make new layer and assign to NGUI Texture, change the camera depth value. but still not working. Then finally I created simple plane and apply texture, make it background. but it create another drawcall which i don't want. Thanks for your reply if any other solution you find pls let me know \$\endgroup\$ – Aks Nov 17 '14 at 10:55
  • \$\begingroup\$ Have you set the camera culling masks? It's very important step, but you don't mention anything about it. \$\endgroup\$ – rutter Nov 17 '14 at 22:40
  • \$\begingroup\$ yes, i have also set camera culling mask for both, for UI Camera, choose only NGUI Layer, and for main Camera, choose everything but not included NGUI layer. \$\endgroup\$ – Aks Nov 21 '14 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.