Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: 4everlove on November 28, 2012, 01:10:39 AM

Title: How to keep showing 2D UI when doing 3D camera transition
Post by: 4everlove on November 28, 2012, 01:10:39 AM
Hi,

I'm doing a cross fade transition between two 3D cameras, using RenderToTexture technique and change the alpha of texture. Meanwhile I need to keep showing an HUD no matter which 3D camera is active and whether under transition. However, I found 2D UI will also has a fade in effect when I do the cross fade. In my case, is there any way to not fade in 2D UI when transition happens?

Thanks!
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: ArenMook on November 28, 2012, 02:02:03 AM
Just do your render to texture before you draw your UI, like so:

3D camera -> renders to texture
2D camera -> draws the texture
2D camera -> draws the UI
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: 4everlove on November 29, 2012, 12:55:56 AM
Thanks, Aren. I'm still little confused. I will do the RenderToTexture work in the middle of the game. How can I control the abovementioned sequence in my case?
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: ArenMook on November 29, 2012, 07:16:18 AM
Camera's depth controls the draw order.
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: 4everlove on November 30, 2012, 02:06:47 AM
Thanks, I see. So according to your description, I need to use NGUI's 2D camera to draw the texture, am I right? Because right now, the 3D camera and 2D camera are in the right sequence, and I use Unity's own OnGUI function to do the fade in, such as

  1. GUI.depth = -1; // 3D -2, 2D 0
  2. GUI.color = new Color();
  3. GUI.drawTexture();
  4.  

And it does not work.
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: ArenMook on November 30, 2012, 05:54:28 AM
OnGUI is not NGUI. Don't confuse or mix the two. I also can't help you if you use Unity's GUI as it's not in any way related to NGUI.

Depth is specified on the Camera, not GUI.
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: 4everlove on December 02, 2012, 09:26:00 PM
Hi, Aren. I'm sorry that I might not state the problems clearly. I do use NGUI except that I use OnGUI function only for the transition effect because I saw a code snippet showing this way. I use 3D cameras (with UICamera attached) for showing both 3D objects and 3D UI(pure NGUI widgets), while a 2D camera (with UICamera attached) shows persistent HUD(pure NGUI widgets as well). Now according to what you said, it seems I should use a 2D camera to draw the texture in between 3D camera and 2D camera and use the depth of camera to maintain the render sequence. Does that mean I need another 2D camera (with UICamera attached or not?)? And will you please show me some simple snippets to achieve this?

Thanks!
Title: Re: How to keep showing 2D UI when doing 3D camera transition
Post by: ArenMook on December 03, 2012, 10:38:55 AM
To display a texture on the screen (and this can be a RenderTexture as well), use UITexture (using the widget tool it's called "Simple Texture").