Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: g0vi on December 10, 2014, 11:31:20 AM

Title: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated
Post by: g0vi on December 10, 2014, 11:31:20 AM

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?
Title: Re: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated
Post by: ArenMook on December 11, 2014, 09:00:15 AM
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.
Title: Re: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated
Post by: g0vi on December 11, 2014, 09:46:36 AM
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
Title: Re: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated
Post by: g0vi on December 11, 2014, 12:03:55 PM
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.
Title: Re: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated
Post by: ArenMook on December 12, 2014, 11:25:47 PM
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;
Title: Re: Scrollview/UIGrid/Center on Child odd behavior when parent UIPanel is rotated
Post by: g0vi on December 15, 2014, 09:48:51 AM
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;