getting unity's UI text as a string.
I have a text component in canvas, which is being fed by a time counter.
I made another script which can modify it's content, however I can't read it to send to a highscore table.
I'm trying:
#pragma strict
var collectSound: AudioClip;
var timeCounter: UnityEngine.UI.Text;
.
.
.
function sendScore{
var timeHs = timeCounter.text;
print ("the value is" + timeHS);
// some more stuff to send high score
}
How do I get the string / value as string contained in the text component?
Comment
Best Answer
Answer by Firedan1176 · Sep 28, 2015 at 12:05 AM
timeCounter.text.ToString();
Thanks, did worked for most texts, for my specific case I ended up exposing the variable and referencing it from script, I guess it has to do with the generating counter script / compilation order.
Regards.