Author Topic: UIPanel clipping misaligned after the localPosition is changed  (Read 2331 times)

neilb

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UIPanel clipping misaligned after the localPosition is changed
« on: January 08, 2014, 05:57:09 AM »
I've just updated to latest NGUI 3.0.8 f7 from an earlier version of 3 running on Unity 4.3.1 f1 on a Mac.

I have an object with a UIPanel + UIScrollView that covers the screen and contains a UIGrid showing an array of buttons representing levels. The user can switch pages by dragging the buttons left or right, after which the panel will slide out of view, swap to the other side of the screen, then slide back into view, simulating multiple pages.

This is the process:
SpringPanel.Begin to move the panel offscreen
transform.localPosition to swap it to the other side of the screen while hidden
SpringPanel.Begin to move it back into view

The problem is that the purple clipping rectangle will be left behind after the call to transform.localPosition and no longer line up with the panel when it reaches it's final location at the center of the screen. It'll be about one panel width to the left or right of where it should be and it doesn't move with the second call to SpringPanel like it did with the first call. This means the buttons won't respond to clicks anymore.

If I set clipping to None on the UIPanel after the app starts (clipping auto-activates at run time), the buttons will continue to work after the panel has moved. This is how I've worked around the problem for now.
« Last Edit: January 08, 2014, 07:51:57 AM by neilb »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel clipping misaligned after the localPosition is changed
« Reply #1 on: January 08, 2014, 12:30:51 PM »
Why don't you just use a single scroll view? Among other features you can have page swiping logic by using UICenterOnChild's "Next Page Threshold" field. It's zero by default, but set it to some value in pixels (such as 50 for example), and if you swipe more than 50 pixels, it will just go to the next element (page).

neilb

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIPanel clipping misaligned after the localPosition is changed
« Reply #2 on: January 08, 2014, 06:47:53 PM »
I am using a single scroll view. Rather than creating a dozen pages of identical buttons, my code is using one page and moving it around off-screen to give the illusion of multiple pages.

I have a workaround. This is just a report that the something has broken in the last month or so.