Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: gamedivisionuk on May 18, 2014, 05:09:43 PM
-
i have an app that has one line of text per item when i click save i need to be able to save that to a scrollable view using a label,each time i create a new item i need to add it to that scrollable view could be around 150 items that need adding to that scrollable view
im using playmaker at the moment when adding another label at runtime it creates it on top of the previous, anyway of the labels being able to reposition themselves within the scrollable view
thank you
-
I use this to create the objects on scrollview grid ....Should be able to create your label as a prefab and do the same
GameObject addnewitem = NGUITools.AddChild(YOURGRID.gameObject, YOURLABELPREFAB); // creates a new Grid Item
UILabel[] labels = addnewItem.GetComponentsInChildren<UILabel>();
foreach (UILabel label in labels) { // Checks each label and assigns the values
switch (label.name) {
case "MYLABELNAME":
label.text = STUFFTOADD;
break;
then call YOURGRID.Reposition();
i have multiple labels and not just one so theres probally a better way for that then using a switch but the basic idea is the same i would think
-
thanks for that i am using a prefab but its the relocation it creates it on top of the original
I use this to create the objects on scrollview grid ....Should be able to create your label as a prefab and do the same
GameObject addnewitem = NGUITools.AddChild(YOURGRID.gameObject, YOURLABELPREFAB); // creates a new Grid Item
UILabel[] labels = addnewItem.GetComponentsInChildren<UILabel>();
foreach (UILabel label in labels) { // Checks each label and assigns the values
switch (label.name) {
case "MYLABELNAME":
label.text = STUFFTOADD;
break;
then call YOURGRID.Reposition();
i have multiple labels and not just one so theres probally a better way for that then using a switch but the basic idea is the same i would think