Author Topic: Sudden UIPanel Problems (clipping and dragable)  (Read 4006 times)

sburgoon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Sudden UIPanel Problems (clipping and dragable)
« on: January 12, 2013, 08:43:07 PM »
So I've been using NGUI for a while and all of the sudden some of my UI that was previously working stopped. It's not a part I test very often, so I'm not sure what change caused it (an NGUI update, or a Unity update, or something else), but I do know I haven't actually touched the UIObjects since they were working. So, what's happening is two-fold. One, the UIDraggable Panel script is ignoring the Scale attribute. It is set to 0, 1, 0, but is allowing dragging in all directions. The other issue is that clipping has stopped working. Instead of soft-clipping, its now just hiding all the panel contents all the time. I checked the gizmos, and they are all in the right place. In the editor, it doesn't work right either, except in the camera preview for the relevant uipanel.

So, anyway, I'm lost. The setup is as follows:

UIRoot->UIAnchor->ParentPanel(NoClipping)->(UIDraggablePanel with soft clipping)->child labels to be clipped
and then, as a sibling of the UIDraggablePanel, is a sliced sprite with UIDrag Panel Contents and a box collider.

I thought it might be the parent panel, so tried removing it, and that made it look correct in the editor, but it still fails completely when I play. My general camera/ui setup is a separate UIRoot and UICamera for each UI "layer" (so, I have one inventory root and camera, one game overlay root and camera, ect). Like I said initially, all this worked perfectly a month or two ago, but when I came back to it after not having tested/used it in a while, it was all broken. Any ideas?

-Sean

sburgoon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Sudden UIPanel Problems (clipping and dragable)
« Reply #1 on: January 12, 2013, 09:06:31 PM »
Updated Info:

So after more experimenting, I figured out the clipping issue. To handle UI scale I scale the UIAnchors above the panels. I was only scaling in X and Y, leaving Z as 1f, because zscale made no sense to me, but apparently doing that breaks the clipping. I think I read something about non-uniform scale breaking clipping in another post, so I have no idea how that's worked up until recently, but clearly my bad.

However, the UIDraggable scale not working is still an issue. I find that if I restrict it to X axis only (1,0,0) it actually works and only moves in X, but if I restrict it to Y only (0,1,0), it still moves in X.
« Last Edit: January 12, 2013, 09:14:04 PM by sburgoon »

sburgoon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Sudden UIPanel Problems (clipping and dragable)
« Reply #2 on: January 12, 2013, 09:55:05 PM »
Ok, I figured it out. My ultimate parent object had a 90 degree rotation in Y. This seems to completely confuse the way the scale value clamps the movement. clamping it later in the process might actually fix it (I took a quick look at the code, and it clamps, but then gets TransformDirection applied a few times before and during the MoveAbsolute and MoveRelative functions, which ends up unclamping it essentially). Either way, it's working for me now, since I just un-rotated the parent object, but might be worth re-working the clamping code so it works in local-space regardless of parent rotations.

-Sean

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sudden UIPanel Problems (clipping and dragable)
« Reply #3 on: January 13, 2013, 12:27:47 PM »
It's not using locals because if the panel is rotated, it should still behave as you would expect. Try the scroll view example and click the "Click Me" button that rotates the window 180 degrees, then swipe the scrollable panel around.

sburgoon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Sudden UIPanel Problems (clipping and dragable)
« Reply #4 on: January 14, 2013, 02:07:29 AM »
I can see not clamping local to itself, but it seems like it should be local to its parent, or at least the UICamera. Also, regardless of the locality, it isn't behaving as expected. I had a top-node rotated (0, 90, 0), a few other nodes (0,0,0), then the UICamera, Anchor and Parent Panel and finally the panel in question, all (0,0,0). The draggable Scale is (0,1,0), so regardless of locality, it should only be allowing dragging in 1 axis, but it ends up allowing it in X and Y (relative to camera).

Anyway, I have it working now either way, but just wanted to mention that part in case that isn't expected.