How do i access Text Object with the new UI???

Hi there, i am currently using the open beta of V. 4.6 and i am in a predicament because i need to access the Text area of several text objects from the new 4.6 beta but i am totally clueless! i have tried to get access to the Text (Script) in MonoDevelop without any luck, and i have tried using guiText without any luck… what am i doing wrong??? and yes i need to modify some text inside the UI Text object in runtime in order for the player(s) to get a better experience :slight_smile: Thanks for any kind of help i can get.

1 Like

I’m not sure it’s the absolute best way to do it (I wish we could bind a public property to Text like we can do for sliders), but I do it like this:

using UnityEngine.UI;
public Text mytext;
void Start () {

        mytext.text = "Hello world";
 
    }

Then in Inspector choose the right Text object for the public mytext field.

6 Likes

Melang - Seriously thank you so much, i should have known that but i didn’t even remotely think of that solution :open_mouth:
You’re awesome Thank you so much for your help :wink:
Cheers,

1 Like

I missed that as well and was assuming the UI collections were included with the UnityEngine. Thanks for chipping in.

var theTextComponent : UI.Text;

function WriteToTextComponentTextField () {
     theTextComponent.text = "This is the actual field."
}
4 Likes

THANK YOU! I normally only see C# codes, but you actually gave the JS. Which is nice since that’s all I am using for my project!

what does right text mean