Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Johan · Mar 02, 2010 at 04:50 PM · colorfont3dtext

Change color of 3D text or font

The 3D text and font systems in unity seems quite broken. How do I change the color of a font or 3D text?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
17
Best Answer

Answer by Waz · Apr 26, 2010 at 11:10 AM

This works for me:

  1. Add a font (eg. a TTF from http://1001freefonts.com) to your project Assets.
  2. Expand it's children in the view - you'll see a "font texture" and a "font material" under each typeface in the font.
  3. Set the size of the font in the "font texture" (duplicate all this to get more sizes, or scale when using).
  4. Right click on the "font material" of a font, select "Create -> Material" (or select it and choose Material fron the Create menu).
  5. You should get a new "font material" added. I recommend renaming it too " - ".
  6. Select the new "font material", and set its Font Texture to the texture of the font you created it from.
  7. Now finally, set the color on this "font material".
  8. Repeat steps 4-7 for each color.

You should see something like this in your Project panel:

  • Fonts
    • Helvetica
      • helv
        • font Texture
        • font material
      • helv - green

With the above set up, whenever you create a 3D text, you must select the font in the Project, then Create the 3D text, then select the other font material in the new 3D text. If you don't pick them right, you just get junk text or text that is not at the right position in space.

This may seem "broken", but you need to understand how fonts work in games: they are bitmaps rendered with a shader, not TTF outline path drawings. Unity allows you to just drop in a TTF and it makes the bitmaps for you, but it's not a DTP program ;-).

Next, you'll want to know how to make it go behind other objects.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jason0202 · Feb 20, 2012 at 07:24 AM 0
Share

@warwick you saved my day. thanks :)

avatar image serff · May 22, 2013 at 08:47 PM 0
Share

You left out one step. You have to make sure to set the Shader of the new material to GUI/Text Shader. Put that at like step 6.5. You should see the preview change from a solid color to text wrapper around a sphere.

avatar image sanks007 · Oct 10, 2013 at 05:34 AM 0
Share

I am trying to do the same. But the font $$anonymous$$aterial part is disabled for almost all the font that i have tried importing which include museosans,segoe,teen,veteran_typewritter,digital,verdana.. what can be the reason for this

avatar image LijuDeveloper · Nov 19, 2013 at 09:35 AM 0
Share

Good solution

avatar image
4

Answer by Eric5h5 · Mar 02, 2010 at 09:21 PM

Neither 3D text nor regular text are "broken". For 3D text you change the color the same way as any other object, by using renderer.material.color. If you're using text in an OnGUI function, change GUI.color.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
4

Answer by rocket5tim · Mar 03, 2010 at 01:27 AM

Find your font in your project folder (inside unity), then click the little "down arrow" next to the font name. Under the font you'll see a "font material" and a "font Texture". Select the font material and in the inspector there's a Text Color field with a white rectangle next to it. Click the white rectangle and choose a new color from the color picker.

All of this assumes that you've added a TTF font to your project. I don't think it's possible to change the color of the default font (Arial Rounded Bold) since it's not exposed in the project.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by headkit · May 04, 2010 at 07:56 AM

try something like

var theColor = new Array(0, 0, 1); var clr = Color(theColor[0], theColor[1], theColor[2], 1);

// if your gameObject has a Child you want to change color gameObject.transform.Find("Your Child to Change Color").gameObject.renderer.material.SetColor ("_Color", clr); // or directly // gameObject.renderer.material.SetColor ("_Color", clr);

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · May 04, 2010 at 09:16 AM 0
Share

Using Arrays like that is a strange idea...just set the values directly ins$$anonymous$$d, it's much faster and easier. Also you can just use renderer.material.color = myColor, no need to use SetColor for that, and you can leave out gameObject in that case too.

avatar image headkit · May 05, 2010 at 07:32 AM 0
Share

you're right, man.

avatar image
0

Answer by Rich · Nov 05, 2010 at 07:57 PM

I read Warwick's answer, and the thing that made it work for me, in Unity 3, is to be sure to set the Shader to be "GUI/Text Shader" rather than the default "Diffuse" when I replaced the Font material with my new, colored font material.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is there a way to measure the pixel with/height of a string with a given font? 2 Answers

How do I change the font and color of GUI text? 0 Answers

Custom font in GUI.Label, but can't change it's color 6 Answers

Script loads font, how do I change the color? 2 Answers

How do I change the font and color of GUI text? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges