Author Topic: Camera Problems  (Read 11726 times)

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Camera Problems
« on: June 21, 2012, 05:46:00 AM »
I'm stumped on something really simple. Hoping someone can give me some hints.

I have my UI camera - default setup by NGUI. It's at depth 0. UI layer only.

I also have my main camera. Can't see the UI layer. If I set it to a depth below 0, I can see the UI stuff, but it's just over a black screen. If I set the main camera depth to something above 0, all I see is a black screen.

Can't figure out why my main camera appears to not be rendering anything.

Any pointers?

PhilipC

  • Guest
Re: Camera Problems
« Reply #1 on: June 21, 2012, 11:34:56 AM »
This more a question for the Unity forums then with NGUI but...

Check your scene view insure that the frustum of the 3D camera is pointing at some object that is not on the UI layer. My guess would be that nothing is in your scene.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Camera Problems
« Reply #2 on: June 21, 2012, 02:27:44 PM »
Game camera should have clear flags set to "depth only".

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Camera Problems
« Reply #3 on: June 21, 2012, 03:48:42 PM »
Game camera should have clear flags set to "depth only".

Thanks - had missed that step.

Still not working though - I can either see the UI camera stuff (with a black, fulscreen background), OR the game camera stuff - by changing the Depth values around. I can't see BOTH.

The only difference in this project compared to others I've done is that the UI is being created in an earlier scene (with a DontDestroyOnLoad). Not sure if that "confuses" it somehow when it enters the actual game scene and the other (main) camera is also suddenly in the scene?

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Camera Problems
« Reply #4 on: June 21, 2012, 03:52:03 PM »
OK - just decided to play with the Clear Flags to see what happens. With the Main Camera set to Depth Only, and the UI camera set to Don't Clear, things start working.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Camera Problems
« Reply #5 on: June 21, 2012, 03:54:28 PM »
OK - so it's not the "game camera" that should be Depth Only. I've now set that on the UI, and changed the MainCamera back to it's Skybox setting and we're all up and running.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Camera Problems
« Reply #6 on: June 21, 2012, 05:21:38 PM »
Sorry I interpreted your post as game camera drawing after the UI camera. First camera to draw should clear everything. Follow-up camera should only clear depth.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Camera Problems
« Reply #7 on: June 21, 2012, 05:34:42 PM »
Sorry I interpreted your post as game camera drawing after the UI camera. First camera to draw should clear everything. Follow-up camera should only clear depth.

Thanks mate - I appreciate the help! :)

Madgodz

  • Guest
Re: Camera Problems
« Reply #8 on: July 18, 2012, 01:59:29 PM »
I'm having similar issues (pro version) with the UICamera and the MainCamera playing nicely.   World is rendering correctly but I'm not getting my character health bars displaying over their heads (like the Workshop demo).   When I deactivate the MainCamera, the health bars show up and I can still see last frame rendered by the MainCamera (only clears depth so this is expected).

MainCamera is dynamically added to scene.  Clear flags: Skybox.  Depth 0.  Perspective.  Far clip: 2000.
UICamera is statically added to scene.  Clear flags: Depth Only.  Depth 0.   Orthographic.  Far clip: 2.

Edit:  OK, this is odd.  While I'm playing, if I change the UICamera depth to a non-zero number, THEN change it back to 0, everything renders fine.
« Last Edit: July 18, 2012, 02:02:59 PM by Madgodz »

PhilipC

  • Guest
Re: Camera Problems
« Reply #9 on: July 18, 2012, 02:07:08 PM »
No thats not odd at all. Having both depths set to 0 you are letting Unity order the cameras how ever it wants (this is most likely just a list they run through). When you set the depth of the UI to some other value Unity reorders its list such that the non zero depth would be called last. When you then change the value back to 0 Unity would not reorder the list as it technically still in a valid position. So you need to insure that your UI camera is about the game camera in terms of depth.
« Last Edit: July 18, 2012, 02:39:28 PM by PhilipC »