Author Topic: Having trouble when I use perspective camera with UI camera  (Read 8231 times)

rigmarole

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Having trouble when I use perspective camera with UI camera
« on: March 22, 2015, 09:10:36 AM »
I'm trying to use unity 5.0.0 with NGUI 3.8.0.
Everything seems to work nicely except....

When I switch my "Camera" under "UI Root" from orthographic to perspective, two things will go wrong.

1)
Once I reopen my project, I receive errors like this:
"Screen position out of view frustum (screen pos 0.000000, 0.000000, 5.005000) (Camera rect 0 0 0 0)"

2)
When I try to make prefabs by draggin game objects into project window,
Many game objects names "UI Root" will appear...

Even if I open a new scene and only create one NGUI sprite in it, same error will occur...


Please help me about it!  Thanks...




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #1 on: March 22, 2015, 10:08:51 AM »
1) Check the settings on your Camera. This isn't NGUI-related.

2) http://www.tasharen.com/forum/index.php?topic=12768.msg57955#msg57955

rigmarole

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #2 on: March 22, 2015, 11:01:04 AM »
1) Check the settings on your Camera. This isn't NGUI-related.

It's easy to reproduce...

1) New Scene
2) Create an arbitrary UIWidget (or UI Sprite). An "UI Root" and a "Camera" will be created automatically.
3) Change the "projection" setting in Camera to "Perspective"
4) Reopen unity project, errors message appears.

The error messages only appeared when there are some NGUI stuffs.
And all of camera's settings are default.


2) http://www.tasharen.com/forum/index.php?topic=12768.msg57955#msg57955


It works! Very thanks~~


Edit: Sorry about that. After some attempting, problem is still there...



« Last Edit: March 22, 2015, 08:22:14 PM by rigmarole »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #3 on: March 23, 2015, 09:38:23 AM »
As I mentioned, check your camera settings. When you create a 3D UI using the NGUI menu it will position the camera correctly and set everything properly. Changing a 2D UI to a 3D UI is more involved than simply altering the camera's field. You also need to set near/far clipping and move it back a bit at the very least.

rigmarole

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #4 on: March 23, 2015, 09:45:59 PM »
I start a new Project, create a new scene, import NGUI 3.8.0 and use NGUI menu create a 3D UI.  (Unity 5.0.0)

Save project and reopen it, error message appears...

I don't think there is anything not set properly. (See the attachment please)

(Actually, all graphics will work properly expect the error message. Those messages are very annoying...)


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #5 on: March 24, 2015, 10:37:17 AM »
Try turning off occlusion culling on the camera.

rigmarole

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #6 on: March 25, 2015, 09:29:39 PM »
I tried, but same problem...  :(


== Edit ==

The problem is happened to the static function "GetWorldCorners" in NGUITools.cs

Inside, when I choose perspective camera, it calls the "ViewportToWorldPoint" of delivered camera.
I've check basic parameters of that camera, all of them seems to be correct.

But when I try to use "ViewportToWorldPoint" and "WorldToViewportPiont" at this moment, these two method are broken!
I guess the inner variables are not fully initialized at that moment...

It only happened when I just start the editor.


« Last Edit: March 25, 2015, 10:33:46 PM by rigmarole »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Having trouble when I use perspective camera with UI camera
« Reply #7 on: March 27, 2015, 10:49:37 PM »
One of many oddities in Unity 5 I suppose.