Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: MedalOfMode on August 23, 2013, 05:14:54 AM
Title:
Script Question
Post by:
MedalOfMode
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
(
)
)
;
}
Title:
Re: Script Question
Post by:
rain
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
(
)
;
}
Title:
Re: Script Question
Post by:
sabba2u
on
August 23, 2013, 09:29:47 AM
Try...
scoreLabel.GetComponent<UILabel>().text(score.ToString());
Title:
Re: Script Question
Post by:
OnlineCop
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 :-)
}
}
}
;
;)
Title:
Re: Script Question
Post by:
MedalOfMode
on
August 23, 2013, 03:31:02 PM
There is no text in screen? Can't we show text using script :o Really, i tried a string too but really there is no text on screen.