Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hansthered

Pages: [1]
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:

  1. theGrid = GetComponent<UIGrid>();
  2. theGrid.Reposition();

However, the grid does not seem to change.

I add labels like this:

  1.                 GameObject clone = (GameObject) Instantiate(playerFoodStuffsLabelPrefab, new Vector3 (0, 0, 0), Quaternion.identity);
  2.                 theGrid.AddChild(clone.transform);
  3.                 clone.transform.localScale = new Vector3 (1, 1, 1);
  4.                 newLabel = clone.gameObject.GetComponent<UILabel>();

I remove labels like this:

  1.                 kidCount = theGrid.GetChildList ().Count;
  2.  
  3.                 for(int i=1; i< kidCount; i++){
  4.                         Destroy (theGrid.GetChild(i).gameObject);
  5.                 }

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,

Pages: [1]