Author Topic: NGUI Camera size must be 1?  (Read 9397 times)

realblues

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
NGUI Camera size must be 1?
« on: May 02, 2012, 11:17:18 PM »
When I changed NGUI Camera size to 100, some methods seems not work properly like scrolling, Panel clipping.

because I was working sprites with 2D toolkit before. 

problem was, new Scene's Default orthographic camera size set to 100, not 1, so every working was set to it includes animation.

now I got camera size 100 for sprite objects and 1 for NGUI.

but sometimes UI needs interactive with sprites position, it requires many coordinates converting now.

is there good solution?
« Last Edit: May 02, 2012, 11:40:05 PM by realblues »

MaskedPixel

  • Guest
Re: NGUI Camera size must be 1?
« Reply #1 on: May 03, 2012, 07:51:28 AM »
Could you please describe the math behind this?  I am having problems with touch input due to the same problem: http://www.tasharen.com/forum/index.php?topic=245.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Camera size must be 1?
« Reply #2 on: May 03, 2012, 08:44:54 AM »
When you create a new UI using NGUI's "Create New UI" wizard, it will set the camera's size to be 1. Unity defaults to ortho camera size of 100 only if you create it yourself manually. '100' doesn't make sense as it has no relation to screen size in either view space (which is 1), or screen space (which is the height of your screen).

Change your 2D Toolkit's camera to 1, then shrink the root object of what it sees by 1/100th by setting its scale to (0.01, 0.01, 0.01).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Camera size must be 1?
« Reply #3 on: May 03, 2012, 08:51:55 AM »
Could you please describe the math behind this?  I am having problems with touch input due to the same problem: http://www.tasharen.com/forum/index.php?topic=245.0
Math behind this? As in, the conversion math? You'll need to read Unity's docs. I didn't code it. Btw, since the ortho size of the camera is '1', it makes sense that the origin of your ray is no more than 1 in any direction. Think about it -- add a box into the scene at the camera's position. By default it's also the size of 1, meaning it will cover the camera's volume nicely. When you convert from screen to world, you get a point inside that box.

realblues

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: NGUI Camera size must be 1?
« Reply #4 on: May 03, 2012, 09:18:05 PM »
Reduding sprite size works well, Thanks :)