Author Topic: Why is NGUI backwards in the editor?  (Read 7975 times)

makeshiftwings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Why is NGUI backwards in the editor?
« on: July 12, 2012, 03:30:03 PM »
Something I've always found strange - why is NGUI flipped in the editor?  You need to look at it down the negative Z axis for it to be facing the right way, and yet when you're actually setting values it still treats it as if you're looking at it normally; with positive Z being further away from the camera and positive X being to the right, rather than the way it is in the editor, with positive Z being closer and positive X pointing to the left.  I never could figure this out exactly; what's the deal?

makeshiftwings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Why is NGUI backwards in the editor?
« Reply #1 on: July 12, 2012, 03:40:00 PM »
Just as an experiment I tried rotating the UI Root 180 degrees on the Y axis so that everything is facing correctly, and everything seems to work fine still, so why does the default UI Root have a flipped Z-axis?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Why is NGUI backwards in the editor?
« Reply #2 on: July 12, 2012, 04:46:54 PM »
Huh? UIRoot doesn't have a rotation.

makeshiftwings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Why is NGUI backwards in the editor?
« Reply #3 on: July 16, 2012, 07:05:10 PM »
Yes, UIRoot's default rotation is 0,0,0, I was just saying that if I changed it to rotate around the Y-axis 180 degrees, it fixed the problem.  When I create a new UI, everything in the editor is flipped backwards when looking down the Z-axis (in other words, it appears to be rotated 180 degrees about the Y-axis, even though all of the objects have zero rotations in the inspector).  In order to see the UI properly in the editor, I have to look at it down the -Z axis instead of the +Z axis.  I assumed it was like this for everyone; maybe it's just something weird in my setup?  All the example projects loaded like that as well though.  I was saying I could get it to look correct by rotating the UIRoot around the Y-axis since the rest of the UI is a child underneath it.  Am I the only one who sees it backwards?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Why is NGUI backwards in the editor?
« Reply #4 on: July 16, 2012, 07:29:36 PM »
Uh... rotate your scene view camera. When looking at the gizmo in the top-right corner, you should see this:
« Last Edit: July 16, 2012, 07:31:23 PM by ArenMook »

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: Why is NGUI backwards in the editor?
« Reply #5 on: July 16, 2012, 08:00:24 PM »
This is because Unity's default orientation in the Scene View is looking back at the origin from the middle of (+X,+Y,+Z), which is actually "backwards" in terms of proper scene orientation where +Z is "deeper" into the scene and -Z is "closer" to the camera.

Typically world space with a default orientation camera is thought of as:
-/+ X : left/right
-/+ Y : down/up
-/+ Z : closer/further from camera

Blame Unity's default orientation when you click the middle of the Scene view axis indicator gadget for making you think this is backwards.

makeshiftwings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Why is NGUI backwards in the editor?
« Reply #6 on: July 18, 2012, 03:33:40 PM »
Thanks JRoch, that's the explanation I was looking for.  I knew it looked correct when you changed the scene orientation to "Back" instead of "Front", but that's why I assumed it was backwards.  I get it now... you're right, it's because Unity's default perspective view is looking at the scene backwards.
« Last Edit: July 18, 2012, 03:36:23 PM by makeshiftwings »