Hello forum!
I have posted this question to unityanswers as well, but so far have not received any response (I admit I only posted it yesterday, so something might still turn up there), and I thought it wouldn't hurt to post it here as well.
I have a table in a scrollview which I dynamically fill from code. I iterate through an array of dataobjects, filling the data into a prefab-widget. This part works flawlessly.
After the elements are all in the table I call the Reposition-method, but it is not properly executed. The padding between the elements in the table is much wider than I have set it. The only ways to properly Reposition() the tables elements I have found so far are a) right-clicking the table and choosing "execute" from the context-menu (which the end-user obviously can't do) and b) adding Reposition() to the update-function having it execute every frame (sounds like a bad idea considering performance?)
What I tried so far:
- putting Reposition() in Update() with a boolean/if-condition that makes it execute only once
- trying the same with LateUpdate()
I have not had any success so far. The functions themselves work ok, but they seem to have no effect on the table.
for(int i = 0; i < _items.Length; i++)
{
var itemInstance = NGUITools.AddChild(ItemsPanel, ItemPrefab);
var item = itemInstance.GetComponent<PrefabScript>();
item.Icon.SetTexturePath = _items[i].IconPath;
item.Level.text = _items[i].text;
item.NotPresent.SetActive(_items[i].CurrentWeapon);
}
// make table sort itself
// it doesn't work properly, no clue why
ItemsPanel.GetComponent<UITable>().Reposition();