1
NGUI 3 Support / Re: How to Refresh UIGrid via code?
« on: September 18, 2014, 10:02:01 PM »
I am having a similar issue. I am calling:
However, the grid does not seem to change.
I add labels like this:
I remove labels like this:
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,
- 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);
- 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,
