Support => NGUI 3 Support => Topic started by: patm on March 26, 2013, 07:15:25 AM
Title: Dynamic UITable - almost have it, just cant change text
Post by: patm on March 26, 2013, 07:15:25 AM
I've been messing with UITable for a couple of days and finally have it adding entries dynamically and displaying in all the right places etc. The only problem I have left now is figuring out how to change the text of a UILabel child.
I cheated and used a UITable demo child (Quest 1) and renamed the UILabel to simply "label". If I just instantiate with NGuiTools I get the proper number of child rows on the table. If I try to change the child text I only get one entry with its original text and no errors reported. THis is the code I'm using
Any clues? It's probably simple as pie by my brain is frazzled!
THanks!
Title: Re: Dynamic UITable - almost have it, just cant change text
Post by: Nicki on March 26, 2013, 08:49:25 AM
Make a helper script on your list entry and get component on that. Inside it, you can have a proper reference to the label you need.
I assume your list entry is a prefab that you instantiate.
Title: Re: Dynamic UITable - almost have it, just cant change text
Post by: patm on March 26, 2013, 01:15:10 PM
Now that I've been away for a few hours and doing completely unrelated stuff I realized my mistake. I got the gameobject that holds "label" then got the object for "label" itself and try to change the text on that. However, that's a transform, not the script attached to the transform. When I get home (at work now) I'll figure out how to talk to the script attached to "label".
Now I have to figure out why newServer.name only gets assigned to the first instance...
Title: Re: Dynamic UITable - almost have it, just cant change text
Post by: patm on March 27, 2013, 06:28:14 PM
For completeness for the next newb like me trying to use the UITable dynamically. In my case I'm trying to make a table of game servers to choose from. I'm using the example "Quest" object & children as a prefab and just changing the text in the main label and the tween label. I changed the names from "Label - Title" and "Label - Text" to LabelTitle and LabelText respectively.
create an instance of the table entry object with NGUITools