color for custom font

when i bring a custom font in unity and use it on guitext the color is always black,
how do you change the color?

You’ll notice the GUIText component in the Inspector panel has a variable called “material”. Create a new material (with whatever colour you like and the shader set to GUI/TextShader) and you can drag it into the material variable to change the rendering of the text.

I haven’t been able to find any info on this.

I want to change the color of my text within a paragraph, or at least within a single scene. Do I need different game objects for each color?

Example: in the following code I would like the color for the text string “myVenueName” to be a different color.

	guiText.font = font1;
	guiText.material.color=Color.yellow;
	guiText.text = myVenueName+"\n\nMike Smith\n\n\n"+someScript.ctrAiName;

Using separate objects would be pretty tedious since I’d have to use “Get” to retrieve the text string from another script. Any advice?

This thread has some code that might be of use to you.

i gave that a try but the font goes weird than :frowning:

Les,
I’ve had to deal with this a couple times, so I figure I’d write out the steps to do us both a favor:

  1. Create a brand new Material (ignore the auto-generated ‘font material’)
  2. Change the new Material to have the ‘GUI / Text Shader’ shader
  3. Drag the ‘font Texture’ from under the TTF to be the texture of the new Material.
  4. Drag the new Material to the Material variable of your GUIText object

Now you can change the text color via the material you created.

Hope that helps.

Thanks ScatterBrain, that’s been doing my head in for the last half an hour :smile: