- Home /
Changing font material alpha for just one clone
Here's the deal:
I'm using scripting to generate a bunch of prefabs (a cube + a 3D text field). The text field is linked to the cube through a function:
public void LinkText (TextMesh txt) {
this.txt = txt;
txt.font.material.color = new Color(1, 1, 1, 0);
}
which is used in a loop instantiating those prefabs (do notice that alpha for each text instance is changed to 0). In each cube I've got an OnMouseUp method:
void OnMouseUp () {
if (isActive) {
renderer.material.SetColor("_Color", new Color(0.1f, 1, 0.1f, 0.2f));
txt.font.material.color = new Color(1, 1, 1, 0.8f);
isActive = false;
}
}
that should change the color of the cube button and (theoretically) make the text appear visible. Unfortunately it raises the alpha for each text instance, instead of changing it only for the targeted one.
All of the 3D text layers have the same material, but (as seen here: http://answers.unity3d.com/questions/448941 ) accessing that material with .font.material. should make a copy of it.
I should also mention that I'm using the 3D Text Shader, though I'm not sure that it's the cause of the problem. I can provide more code if needed.
Your answer
Follow this Question
Related Questions
Text not reverting back to original properties after gameplay 1 Answer
Modifying the Arial material for fading GUITexts 1 Answer
How to find a font via script? 2 Answers
Editing the alpha of one GUItext edits the alpha of them all 1 Answer
Is there a way to measure the pixel with/height of a string with a given font? 2 Answers