Author Topic: Unity 4 Depth Problem  (Read 11426 times)

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Unity 4 Depth Problem
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 4 Depth Problem
« Reply #1 on: August 24, 2012, 05:18:47 AM »
I'll let Phil answer this one as he did the Unity 4 update.

PhilipC

  • Guest
Re: Unity 4 Depth Problem
« Reply #2 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...

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 Depth Problem
« Reply #3 on: August 27, 2012, 01:56:11 AM »
Sorry for the delayed response - I've been away.

I'm using b7.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 Depth Problem
« Reply #4 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 4 Depth Problem
« Reply #5 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.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 Depth Problem
« Reply #6 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 4 Depth Problem
« Reply #7 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.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 Depth Problem
« Reply #8 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.