x


Text Mesh, change color

Hi everyone, I have this code here, attached to an object with Text Mesh ans Mesh Renderer:

function Update () {
    var myTextMesh = (GetComponent(TextMesh) as TextMesh);
    renderer.material.color = Color.black;
    myTextMesh.text = "name";
}

Its works fine, but if change a little bit, like:

var newcolor : Color = Color.black;
function Update () {
    var myTextMesh = (GetComponent(TextMesh) as TextMesh);
    renderer.material.color = newcolor;
    myTextMesh.text = "name";
}

or ( this is what I want )

function Update () {
    var myTextMesh = (GetComponent(TextMesh) as TextMesh);
    renderer.material.color = transform.parent.renderer.material.color;
    myTextMesh.text = "name";
}

The text becomes invisible!!! What can I do?

more ▼

asked Apr 21 '10 at 01:03 PM

Vinicius gravatar image

Vinicius
16 4 4 8

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Presumably the color you're using has an alpha value of 0. Change the alpha of the color to 1 instead.

more ▼

answered Apr 21 '10 at 05:23 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Thanks! You are absolutely right! =D

Apr 22 '10 at 05:06 PM Vinicius

This was my problem too. I had used the color picker to select a color off a partially transparent object, and it set my picked color to full alpha.

Feb 08 '12 at 09:05 PM adamonline45
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1364
x555
x507
x379

asked: Apr 21 '10 at 01:03 PM

Seen: 9299 times

Last Updated: Feb 08 '12 at 09:05 PM