Hi,
So basically I have a scrollview, utilising a UITable.
Within this table I have some items, some of which are dynamically updated once I get a list of items from the server.
I have the following code which positions the items as children of an item in the table, and then expands the table item (the background of the list) to match the height... I then call reposition on the table.
foreach(GameObject obj in spawned_catagory_items)
{
NGUITools.Destroy(obj);
}
spawned_catagory_items.Clear();
create_event_table_page1.Reposition();
bool left_side = true;
int position = 0;
for(int i=1; i< UserSettings.catagories.Count; i++)
{
if(left_side)
{
left_side = false;
GameObject cat_item = NGUITools.AddChild(catagory_segment, catagory_toggle_prefab_left);
NGUITools.SetActive (cat_item,true);
cat_item.GetComponent<CatagoryToggler>().UpdateCat(UserSettings.catagories[i]);
spawned_catagory_items.Add(cat_item);
cat_item
.transform.localPosition = new Vector2
(0,
-85 - (position
* 70)); }
else
{
left_side = true;
GameObject cat_item = NGUITools.AddChild(catagory_segment, catagory_toggle_prefab_right);
NGUITools.SetActive (cat_item,true);
cat_item.GetComponent<CatagoryToggler>().UpdateCat(UserSettings.catagories[i]);
spawned_catagory_items.Add(cat_item);
cat_item
.transform.localPosition = new Vector2
(0,
-85 - (position
* 70)); position++;
}
}
catagory_segment_sprite.height = 85 + (position * 70);
create_event_table_page1.Reposition();
The issue being that it's not actually repositioning the items and I end up with items overlaying each other.
Attached are screenshots of what I'm getting as a result, and a screenshots of the intended result (repositioned in the editor).
I guess the method I'm using to add items doesn't work with NGUI, but it would be great to get some indication as to how I should go about doing this.
Many thanks.