So I have a problem that might be related to this. In my hierarchy there are these elements:
-Panel
--Header (some sprites)
--Background
--Scrollbar
--ScrollView
---Table
The panel gets enabled/disabled (as it is just a part of the UI). The table has a certain amount of elements, which get activated/deactivated to show the elements I need, but when I do that, the table appears in the middle of the Scrollview instead of at the pivot point (which is set to TopLeft in inspector). As according to the docs on UIScrollView and UITable, I reposition the table after populating its contents and then I reposition the ScrollView:
// activate/deactivate desired table elements...
// and then sort the table and reposition the scrollview
mTable.sorting = UITable.Sorting.Alphabetic;
mTable.pivot = UIWidget.Pivot.TopLeft;
mTable.Reposition();
mTable.transform.GetComponentInParent<UIScrollView>().contentPivot = UIWidget.Pivot.TopLeft;
mTable.transform.GetComponentInParent<UIScrollView>().ResetPosition();
Curiously enought, this only happens the first time the panel that contains the scrollview and the table is enabled. Once I disable the panel and reenable it, everything gets to its position.
I have tried all the combinations with populating the table, repositioning the table and resetting scrollview's position but it doesn't work as I think it should (which is setting the contents of the table to the top left and the table also to the top left of the scrollview). Am I doing something wrong with my code or am I expecting a different behaviour than the intended?
I have attached two images showing what I think I shoud get and another showing what happens.
Thanks
[EDIT Also tried getting the scrollview component using NGUITools:
UIScrollView sv = NGUITools.FindInParents<UIScrollView>(mTable.gameObject);
if (sv != null) {
sv.contentPivot = UIWidget.Pivot.TopLeft;
sv.ResetPosition();
}
And I just debugged it and made sure it does go through that piece of code. Still nothing. Seems like calling either UITable.ResetPosition() or UIScrollView.ResetPosition() (or both) does nothing...