Author Topic: Alignment of ScrollView centering  (Read 5739 times)

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Alignment of ScrollView centering
« on: July 17, 2015, 10:48:45 AM »
Hi there,

I have a ScrollView with a table child and a bunch of entries in it. Pretty simple setup:
+ScrollView
+UITable
+++Entry1
+++Entry2
+++...

When clicking on an item in the table I want it to center on it. This also works well, however I would like to set the position inside the table where the clicked item will be centered. This is how it looks right now:


What would be the best way to set it up so that clicked items align with the top of the ScrollView and not the bottom? Bascially I would like the top border of my entry to be aligned with the top of the visible area of the ScrollView. I hope this makes sense :) I am thinking there might be a simple setting or checkbox I overlooked.
Thanks!
« Last Edit: July 17, 2015, 10:56:32 AM by Holy Manfred »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Alignment of ScrollView centering
« Reply #1 on: July 21, 2015, 10:57:00 AM »
Assuming you used UICenterOnClick / UICenterOnChild, it simply centers on the child transform's position. Sub-children of that child can be moved around as you see fit.

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Re: Alignment of ScrollView centering
« Reply #2 on: July 27, 2015, 09:56:47 AM »
Thanks for your suggestion.
Turns out my issue was related to the parent object of the scroll view. When UICenterOnClick'ing the clicked element would center on the pivot of the parent object of the object holding my scroll view. Not sure if this is intended though, since I was assuming UICenterOnClick would use the pivot of the scroll view an not its parent object. Anyway, to fix it I just had to adjust the center position of the parent widget, so it was an easy fix in the end.