1
NGUI 3 Support / Adding contents to multiple tables in order?
« on: June 24, 2014, 01:27:20 PM »
Basically I have a set of 3 tables, first table is labels, other 2 are textboxes, they are added to dynamically during runtime with different numbers of objects. You can think of it working basically of like a spreadsheet.
For example if my data contents are the following:
Item01 - 1 - 1.11
Item02 - 2 - 2.22
Item03 - 3 - 3.33
Item04 - 4 - 4.44
When I add those to the table, I have a loop to add to my interface using the following code:
Then I call Reposition() for each table at the end.
Even though I added each object to the table in the same exact order, for some reason the textboxes are all mixed up in the order they display. This is the current display I get for the data I listed above:
Item01 - 2 - 2.22
Item02 - 4 - 4.44
Item03 - 3 - 3.33
Item04 - 1 - 1.11
I have no idea why this is happening like this? Sort is unchecked, so I'm not sure how to get them ordered in the appropriate order. Is there any way I could get them always listed in the order that I add them to the table?
Thanks
For example if my data contents are the following:
Item01 - 1 - 1.11
Item02 - 2 - 2.22
Item03 - 3 - 3.33
Item04 - 4 - 4.44
When I add those to the table, I have a loop to add to my interface using the following code:
- // load label object
- var newItem = Instantiate(productLabelObject, this.transform.position, this.transform.rotation) as GameObject;
- newItem.transform.parent = productCodeList.transform;
- newItem.transform.localScale = Vector3.one;
- // load quantity object
- var newItem2 = Instantiate(productTextObject, this.transform.position, this.transform.rotation) as GameObject;
- newItem2.transform.parent = quantityList.transform;
- newItem2.transform.localScale = Vector3.one;
- // load price object
- var newItem3 = Instantiate(productTextObject, this.transform.position, this.transform.rotation) as GameObject;
- newItem3.transform.parent = priceList.transform;
- newItem3.transform.localScale = Vector3.one;
- // set text of label object
- UILabel labelScript = newItem.GetComponent<UILabel>();
- labelScript.text = orderArray[0, yT];
- // set text of quantity object ([2])
- UIInput inputScript = newItem2.GetComponent<UIInput>();
- inputScript.value = orderArray[2, yT];
- // set text of price object ([2])
- UIInput inputScript2 = newItem3.GetComponent<UIInput>();
- inputScript2.value = orderArray[1, yT];
Then I call Reposition() for each table at the end.
Even though I added each object to the table in the same exact order, for some reason the textboxes are all mixed up in the order they display. This is the current display I get for the data I listed above:
Item01 - 2 - 2.22
Item02 - 4 - 4.44
Item03 - 3 - 3.33
Item04 - 1 - 1.11
I have no idea why this is happening like this? Sort is unchecked, so I'm not sure how to get them ordered in the appropriate order. Is there any way I could get them always listed in the order that I add them to the table?
Thanks
