Changing font colour

I have 3 imported fonts in my project, the 'Text Color' button & color picker are ghosted, and do not work.

Is this a bug? I have attempted to re-import the fonts, but the option is still ghosted. I have also imported other fonts. Any ideas?

alt text

Ghosted!?

Definitely, not intuitive:

http://unity3d.com/support/documentation/Components/class-Font.html

Changing Font Color

There are different ways to change the color of your displayed font, depending on how the font is used.

GUIText & Text Mesh If you are using a GUIText or a Text Mesh, you can change its color by using a custom Material for the font. In the Project View, click on Create->Material, and select and set up the newly created Material in the Inspector. Make sure you assign the texture from the font asset to the material. If you use the built-in GUI/Text Shader shader for the font material, you can choose the color in the Text Color property of the material.

UnityGUI If you are using UnityGUI scripting to display your font, you have much more control over the font's color under different circumstances. To change the font's color, you create a GUISkin from Assets->Create->GUI Skin, and define the color for the specific control state, e.g. Label->Normal->Text Color. For more details, please read the GUI Skin page.

As zoon pointed out, you need to create your own custom font material and use that.

The reason is that we don't allow editing of imported assets, only of the import settings - otherwise, this would be a sure way of breaking things when using external version control. However, having an option for font color in the font importer seems like a very reasonable request, though.

Just add a script that does it here is one that makes it red…just change teal to any color you want

function Update () {

renderer.material.color = Color.red;

}

Simple :wink:

This will do :slight_smile:

var tex : Transform;

function Start() {

tex.guiText.text = "Hello";
tex.guiText.material.color = Color.green;

}

Try this code, it’ll allow you to change text mesh color interactively during edit time, and (just to be picky) it won’t change anything during play:

using UnityEngine;

[ExecuteInEditMode]
public class SetTextMeshColor : MonoBehaviour {

	public Color TextColor = Color.black;
	private Material _material ;

	void OnEnable () {
		_material = GetComponent<MeshRenderer>().sharedMaterials[0];
		_material.color = TextColor;
	}

	void Update() {
		if (Application.isPlaying) return;
		_material.color = TextColor;
	}
}

If you just want to change the color, this will make it:

void OnGUI() {
GUI.contentColor = Color.yellow;
GUI.Button(new Rect(10, 10, 70, 30), “A button”);
}