Hey guys!
I have been fighting this issue for awhile now, scrounging the forums and stackoverflow for answers..
I am trying to get my UIScrollView to adjust its size depending on the content in a child table.
What I am doing right now is, I am attempting to use SetRect on the UIPanel, and then call ResetPosition on the scrollview but it is acting really strange.. Here is my code.
public GameObject table;
public GameObject friend;
public GameObject scrollView;
List<Transform> childList;
public float scrollViewHeight;
float childHeight;
int numberOfChildren;
void Start() {
childHeight = friend.GetComponent<UIWidget>().localSize.y + 5;
childList = table.GetComponent<UITable>().children;
Invoke("Resize", 1f); // temp invoke for testing
}
void Resize() {
numberOfChildren = childList.Count;
scrollViewHeight = childHeight * numberOfChildren;
UIPanel panel = scrollView.GetComponent<UIPanel>();
panel.SetRect(panel.clipOffset.x, panel.clipOffset.y, panel.width, scrollViewHeight);
scrollView.GetComponent<UIScrollView>().ResetPosition();
}
The Hierarchy looks like this:
ScrollView Table ChildNow there is probably a lot wrong going on up there, but I have been trying all kinds of things and so far this is the only thing that is remotely working..
I mostly just want the functionality of a native scrollview, when content is added or removed I want the scrollview to be exactly the size of the table, until it reaches screen height, of course..
I would love to hear some suggestions because I am losing my mind.
