Welcome,
Guest
. Please
login
or
register
.
April 30, 2026, 12:52:05 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Leaderboard - Accessing labels of prefab and adding to UIGrid
« previous
next »
Print
Pages: [
1
]
Author
Topic: Leaderboard - Accessing labels of prefab and adding to UIGrid (Read 2824 times)
singh029
Newbie
Thank You
-Given: 1
-Receive: 0
Posts: 28
Leaderboard - Accessing labels of prefab and adding to UIGrid
«
on:
February 26, 2014, 11:26:56 AM »
Hi how do i access and edit a specific label in a prefab and then add it to the UIGrid?
I want to create a leaderboard and each prefab contains a rank label, name label, and score label.
I referenced this post and found how to add children to a parent.
http://www.tasharen.com/forum/index.php?topic=7418.0
But how do i access and edit each label and then add it to the UIGrid
Thank you!
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Leaderboard - Accessing labels of prefab and adding to UIGrid
«
Reply #1 on:
February 26, 2014, 02:16:17 PM »
Dirty way? transform.FindChild("name of your label").GetComponent<UILabel>().
Clean way? Create a script attached to your prefab with public references to the labels you want to edit. You can then GetComponent<YourScript>().headerText = "Whatever";
Logged
singh029
Newbie
Thank You
-Given: 1
-Receive: 0
Posts: 28
Re: Leaderboard - Accessing labels of prefab and adding to UIGrid
«
Reply #2 on:
February 26, 2014, 03:25:40 PM »
I seeeeee! thank you!
So if i wanted to change the text of one of the labels, then i would do something like
var name = transform.FindChild("username").GetComponent<UILabel>();
name.text = "ArenMook";
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Leaderboard - Accessing labels of prefab and adding to UIGrid