I am having a similar issue. I am calling:
theGrid = GetComponent<UIGrid>();
theGrid.Reposition();
However, the grid does not seem to change.
I add labels like this:
GameObject clone
= (GameObject
) Instantiate
(playerFoodStuffsLabelPrefab,
new Vector3
(0,
0,
0), Quaternion
.identity); theGrid.AddChild(clone.transform);
clone
.transform.localScale = new Vector3
(1,
1,
1); newLabel = clone.gameObject.GetComponent<UILabel>();
I remove labels like this:
kidCount = theGrid.GetChildList ().Count;
for(int i=1; i< kidCount; i++){
Destroy (theGrid.GetChild(i).gameObject);
}
The new label does seem to spawn, the foodstuffs do update, but there is a gap in the grid where it looks like another label should be.
The reason I set i=1 instead of 0 is because the first child of the grid is the original prefab object. If i set that to 0 the prefab gets deleted (which I don't want).
Please advise,