Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: stevej on August 24, 2012, 04:40:00 AM

Title: Unity 4 Depth Problem
Post by: stevej on August 24, 2012, 04:40:00 AM
I just upgraded to the latest NGUI in my 3.5 project, and then opened it in Unity 4 just to test things out.

I've got this problem where none of my UI shows up with the old settings. At runtime I've gone and changed the NGUI camera depth from 0 to 1 and that's displayed the main interface, but then other parts of the interface that I enabled via SetActiveRecursively don't display, and I'm assuming that they're buried "behind" other things.

Are there known issues with Unity 4? Anything that needs to be done to a project once it's converted over?
Title: Re: Unity 4 Depth Problem
Post by: ArenMook on August 24, 2012, 05:18:47 AM
I'll let Phil answer this one as he did the Unity 4 update.
Title: Re: Unity 4 Depth Problem
Post by: PhilipC on August 24, 2012, 09:36:29 AM
Which version of the beta are you using? As I have not see this issue with NGUI or Windward in Unity 4...
Title: Re: Unity 4 Depth Problem
Post by: stevej on August 27, 2012, 01:56:11 AM
Sorry for the delayed response - I've been away.

I'm using b7.
Title: Re: Unity 4 Depth Problem
Post by: stevej on August 27, 2012, 06:24:48 AM
I've made a video to demonstrate the issue:
http://www.coldfirekeep.com/temp/ngui_u4_issue.mov

In the first part I'm running the project in 3.5...

In the next bit I launch the EXACT same project in Unity 4b7. You can see that the interface is not displayed unless I increase the camera depth. Also, the dialogue window that is enabled through code (SetActiveRecursively) does not function for some reason - like that code is being "ignored".

Hope the video helps.
Title: Re: Unity 4 Depth Problem
Post by: ArenMook on August 27, 2012, 08:27:50 AM
You're remaking Dungeons of Dredmor? :P

NGUI camera must be drawn after the game camera, so it should have a higher depth anyway. Assuming your game camera is on 0, you need to put the NGUI camera on 1. When you create an NGUI UI using the wizard, it does it for you.
Title: Re: Unity 4 Depth Problem
Post by: stevej on August 27, 2012, 07:15:43 PM
Hmm... question is - why does it work in Unity 3.5 and not in Unity 4? It's the same project with the same settings.

I just realised I've got both cameras set to a depth of 0, so that IS a mistake. But it works in 3.5 without issues.

Also, doesn't explain why the other parts of the UI being activated by SetActiveRecursively() are not working in Unity 4.
Title: Re: Unity 4 Depth Problem
Post by: ArenMook on August 27, 2012, 07:25:18 PM
Depth of 0 means there is no guarantee which one will be drawn first, so it's not surprising that it changed between versions.
Title: Re: Unity 4 Depth Problem
Post by: stevej on August 27, 2012, 07:30:50 PM
OK - let me play around with it later today and I'll see if the other part of the issue is all tied into that somehow.