Author Topic: UIDraggablePanel: Problem with Scrollwheel  (Read 4663 times)

col000r

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 43
  • Mighty Emperor of Planet "Home Office"
    • View Profile
    • BLACKISH
UIDraggablePanel: Problem with Scrollwheel
« on: April 12, 2012, 06:22:26 AM »
I have a UIGrid in a clipped UIDraggablePanel and use it for vertical scrolling. Scale set to (0,1,0), scrollWheelFactor to 1.

Now everything works well if I click and drag or use the scroll wheel after I click-dragged first. BUT if I use the scroll wheel before I ever clicked and dragged, the content goes outside the normal area by about 50% if I scroll up and the scrollbar won't show up. If I then click-drag everything goes back to normal and scrolling with the wheel starts acting as expected as well...
Games: BLACKISH | Blog | Assets

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel: Problem with Scrollwheel
« Reply #1 on: April 12, 2012, 02:05:39 PM »
You're right, there is something odd happening there, and only seems to be the case with a grid. I'm going to look into this, thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel: Problem with Scrollwheel
« Reply #2 on: April 12, 2012, 03:05:55 PM »
Ok, here's how to fix it.

In UIGrid.cs, add this code to the very end of the Reposition() function (end of the file):

  1. UIDraggablePanel drag = NGUITools.FindInParents<UIDraggablePanel>(gameObject);
  2. if (drag != null) drag.UpdateScrollbars(true);

In UIDraggablePanel.cs, add the following code to the end of UpdateScrollbars() function:

  1. else if (recalculateBounds) mCalculatedBounds = false;