Simple question!

Hi

I’ve a very basic problem and I need your help.

I’ve a TextMesh and I want at some time during the program the text changes by other … Just that.

Example: Pressing a button to change the original text for “Hello World!”

I tried to write:

GetComponent(TextMesh).text = "Hello World";

Or

//TEXT1 = Name of TextMesh!
GetComponent(TEXT1).text = "Hellow World";

But it has not worked :frowning:

Thank you!! Sorry for my basic English! (And my basic Scripting)

Grettings :wink:

Hi All,

I have a attribute dimension which has 10 different level 0 member. I am trying to write a report script which gives me the name of the attribute rather then the name of the base dimension members that its is associated with. So as of now when i run the report it gives me a list of all the members from base dimension to which those attributes are attached. I need to know which attribute is assigned to what member?? How can i do this via report script?

Please advise!

@Nicolyto77

Which language you are using ?

@sjohn

Better start a new thread if you want your question to get answered.

–
oxl

Thanks Oxl

Im using Javascript :?

I’m trying everything … but nothing is correct! :cry:

Grettings!

What problems are you having? Are you getting compiler errors or is the text just not changing or… what?

Depends on the wrong code :sweat_smile:

If i Write:

function Start () {
var NewVal : TEXTO = GetComponent (TEXTO);
NewVal.Text = "NewTextHere";
}

Appear:

Assets/Texto.js(3,18): BCE0018: The name ‘TEXTO’ does not denote a valid type.

If i Write:

GetComponent(TEXTO).text = "Hello World";/code]

Appear:

[b]Assets/Texto.js(2,15): BCE0005: Unknown identifier: 'TEXTO'.[/b]

(TEXTO is called my object that shows the 3dText)

[color=blue]---()---[/color]

If i try destroy this object, i need put this code:

[code]Destroy(GetComponent(TextMesh));

And Ok! But if i’ve 3 objects… How do I know which of these objects is destroyed?

My objects are called Texto1, Texto2 and Texto3. How i refer to them by name? Ex: Destroy(GetComponent(Texto1));

Thanks so much

You have to write “TextMesh” where you currently have “TEXTO”. The declaration needs to be the type name rather than the variable name.

I’m having the exact same problem in Unity iPhone.

GetComponent (TextMesh).text = "Some Text";

is not working.

It says
‘text’ is not a member of ‘UnityEngine.Component’.

Does anyone know the reason for this?

GetComponent returns a Component, which indeed has no “text” member, so you have to cast it as a TextMesh.

–Eric

Thank you, Eric!

So it goes like this

var myText : TextMesh = GetComponent (TextMesh);
myText.text = "Some Text";

Yep. If you want to do it in one line, it’s:

(GetComponent (TextMesh) as TextMesh).text = "Some Text";

–Eric