Welcome,
Guest
. Please
login
or
register
.
October 06, 2024, 05:58:45 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Script Question
« previous
next »
Print
Pages: [
1
]
Author
Topic: Script Question (Read 2385 times)
MedalOfMode
Guest
Script Question
«
on:
August 23, 2013, 05:14:54 AM »
Why this script isn't working? I'm trying to show score.
public
int
score
=
0
;
public
GameObject scoreLabel
;
void
ScoreTextShow
(
)
{
scoreLabel
.
GetComponent
(
UILabel
)
.
text
(
score
.
ToString
(
)
)
;
}
Logged
rain
Jr. Member
Thank You
-Given: 2
-Receive: 4
Posts: 79
Re: Script Question
«
Reply #1 on:
August 23, 2013, 08:57:12 AM »
Instead of storing a GameObject, you can create a UILabel field so you don't even need to GetComponent the UILable component.
public
int
score
=
0
;
public
UILabel Label
;
private
void
ScoreTextShow
(
)
{
Label
.
text
=
score
.
ToString
(
)
;
}
Logged
sabba2u
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 4
Re: Script Question
«
Reply #2 on:
August 23, 2013, 09:29:47 AM »
Try...
scoreLabel.GetComponent<UILabel>().text(score.ToString());
Logged
OnlineCop
Jr. Member
Thank You
-Given: 0
-Receive: 0
Posts: 51
Re: Script Question
«
Reply #3 on:
August 23, 2013, 12:27:26 PM »
public
UILabel label
;
private
int
mScore
=
0
;
public
int
score
{
get
{
return
mScore
;
}
set
{
if
(
value
!=
mScore
)
{
mScore
=
value
;
label
.
text
=
mScore
.
ToString
(
)
;
// Automatically updates the label any time the score gets updated :-)
}
}
}
;
Logged
MedalOfMode
Guest
Re: Script Question
«
Reply #4 on:
August 23, 2013, 03:31:02 PM »
There is no text in screen? Can't we show text using script
Really, i tried a string too but really there is no text on screen.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Script Question