Author Topic: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated  (Read 2411 times)

g0vi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile

When I rotate a panel 180 degrees the center on child has a problem when I drag beyond the panel, sending it in the wrong direction. The problem goes away when I set the UIGrid's "Next Page Threshhold" to 0. If the threshold is anything larger than 0 then it acts up.

Here is a quick .gif I made replicating the problem: https://i.imgur.com/wgdz3Xz.gif

Any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
It seems to work as expected in the 7th example that comes with NGUI. Click the button to rotate the window 180 degrees, check the checkbox, and it still works as expected.

g0vi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Thanks for reply,

Comparing it to the Example 7 helped. When I set the sorting on my grid to "None" instead of "Horizontal", the odd behavior stopped.

Thanks!

Joe

Edit: Grammar
« Last Edit: December 11, 2014, 09:51:53 AM by g0vi »

g0vi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Actually! If you are still reading this, according to the UICenterOnChild.cs, "Next Page Threshold requires a sorted UIGrid in order to work properly". So I actually do need "Horizontal" sorting for my threshold to work properly for my rotated scrollviews.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Open up UICenterOnChild.cs, go to line 137:
  1. Vector2 totalDelta = UICamera.currentTouch.totalDelta;
Change it to:
  1. Vector3 totalDelta = UICamera.currentTouch.totalDelta;
  2. totalDelta = transform.rotation * totalDelta;

g0vi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
This worked for the panels at 0 and 180 rotations but not with panels rotated at 90 and 270. So what I did was just set a bool to switch between:

Vector2 totalDelta = UICamera.currentTouch.totalDelta; for 90 and 270 degrees

&

Vector3 totalDelta = UICamera.currentTouch.totalDelta; for 0 and 180;
totalDelta = transform.rotation * totalDelta;