Author Topic: When creating a Vertical Scroll View (Camera) ScrollCamera position is incorrect  (Read 6290 times)

Sarus

  • Guest
I started with Example 8 Scroll View (Camera) as my base.  Instead of a horizontal scroll I wanted a vertical scroll so I changed the "Scale" parameter of UIDraggable Camera Script to have "X=0" and "Y=1".  Unfortunately,  I have not been able to get the "Scroll Camera" to position correctly.  When I start the game the camera moves horizontally to the right and only half of the UITable item is visible in the scroll list (the other half is cut off by the restricted viewport).  Oddly enough, when I try to drag the menu the SpringPosition script activates and moves the scroll item to be almost centered but not quite. 

I know there are a lot of settings so I think I must have missed something somewhere.  In the screenshots below the TopLeft anchor and BottomRight anchor used to define the UIViewport are represented by the small square sprites with the paper background.  Based on this, the viewport appears to be in the correct place but for some reason the Camera positions is adjusted to an incorrect position on start.  Please see attached screenshot which shows the camera positioning problem.  In addition, I attached a screenshot of the inspector values for the "Scroll Camera" (i.e., the camera that is being dragged).

Please let me know if there is other information that I can provide that will help figure out the issue.  Any hints on where to look for the problem would be appreciated.  Thank you!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
What are you using to position the items? Is it UIGrid?

The camera shouldn't be able to move along the X at all if you set the X scale to 0. If you can't figure it out, send me the project to support at tasharen.com, and I'll have a look at it.

Sarus

  • Guest
I am using UITable to position the items into a single column.  The camera doesn't move in the X direction due to any user input.  When the project is first started (i.e., I hit the play button) the camera position is changed (step 2 in the screenshot).  After dragging the items in the scroll list they spring into the sort of middle position (step 3).  At that point the camera only moves in the Y direction when dragging. 


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
UITable is really meant to be used with the clipped panel approach to scroll views. Try using a UIGrid instead.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
For those who encounter this in the future: make sure that you don't have an active UISpringPosition script attached to the camera. That's what was moving it. That said, I doubt anyone else will encounter this particular issue in the future, as UISpringPosition would have had to be added manually in order for this to happen.

Sarus

  • Guest
Thanks again ArenMook,

Make sure you don't copy the Vertical Scroll GameObject from the example while the example is running  ;)  Otherwise you'll have the problem I did haha.