Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by srancsik · Oct 02, 2013 at 01:02 PM · fonttextmesh3d text

SOLVED - 3D Text - How to apply new font type in Runtime

Hello Guys,

Please help. I have the following code to assign a new font type to a TextMesh, the font type is assigned to the TextMesh, but only blocks are appearing instead of the text. If still in Runtime I change to the default built in Arial, everything is ok. What can be the problem? As always, thank you in advance for any suggestion.

 var tm : TextMesh = TheText.GetComponent(TextMesh);
         tm.text = "Some string";
         tm.fontSize=80;
         tm.font= Resources.Load("calibrili") as Font; 


Comment
Add comment · Show 1
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 losingisfun · Mar 30, 2018 at 02:15 AM 0
Share

Thanks to this question, fixed a problem I was having for a few weeks. Please up vote this!

2 Replies

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

Answer by Owen-Reynolds · Oct 02, 2013 at 01:23 PM

Also change the Material.

You can see this not in run-time, with manual changes. Sometimes changing just the font will accidentally look fine, and Ariel+no material usually works. But more often than not you get that same blockiness if you don't create and use a proper Font Material (or using the wrong one produces shifted, rotated letter parts.)

Comment
Add comment · Show 3 · 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 srancsik · Oct 02, 2013 at 03:13 PM 0
Share

Yes, this is causing the problem. $$anonymous$$y only problem is, that I need to run it in runtime and assign the font material in code. I tried it the below way, but apparently it is not working. Can you give an idea how to do it? Thank you for the answer in advance.

tm.renderer.material = Resources.Load("calibrili") as $$anonymous$$aterial;

avatar image Owen-Reynolds · Oct 02, 2013 at 05:39 PM 0
Share

Just to be sure, might need to hand-make a font material (the default may not load properly in run-time.)

Otherwise, I don't use Resourses.Load and have never swapped a font while running. But, the standard "Unity" method might avoid some glitch:

public $$anonymous$$aterial[] Font$$anonymous$$ats;, load them up in the Inspector by hand, in the usual way. Don't need to use an array, but may as well. Then tm.renderer.material=Font$$anonymous$$ats[0];.

avatar image srancsik · Oct 02, 2013 at 08:25 PM 0
Share

Owen, absolutely clear and serves my needs!!! Thank you a lot!

avatar image
4

Answer by Lertulo · Jul 22, 2014 at 04:15 AM

Just came across this: was adding a TextMesh dynamically and all I got out was boxes--capital letters were bigger boxes, sure, but just boxes. As suggested above, the solution was adding the tagged line below:

             TextMesh tm = obj.AddComponent<TextMesh>() as TextMesh;
             tm.characterSize = 0.5f;
             tm.text = "xXx";
             tm.color = Color.green;
             tm.anchor = TextAnchor.MiddleCenter;
             tm.transform.position = new Vector3(0,0,4);
             tm.font = GuiFont;

             MeshRenderer rend = obj.GetComponentInChildren<MeshRenderer>();
             rend.material = tm.font.material;  /* ADDED THIS */


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 Nikola-B · Jul 22, 2014 at 05:13 AM 0
Share

For your text needs, I would look into using Text$$anonymous$$esh Pro which is an incredible alternative to Text$$anonymous$$esh. The quality of the text rendering is just amazing plus the improved text layout options are great.

If you use text in your games or projects, you should seriously check Text$$anonymous$$esh Pro out. I realize it is not free but it is pretty amazing.

avatar image protron · Aug 13, 2014 at 06:48 AM 0
Share

text$$anonymous$$esh.font=newFont; text$$anonymous$$esh.GetComponent().material=newFont.material;

works for me. Thank you for the hint Lertulo!

If I don't add the 2nd line Unity renders distorted characters after setting the new font.

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

17 People are following this question.

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

Related Questions

Jagged and pixelated fonts in text mesh 3d (iphone) 4 Answers

How to Get a Char from his name ? 1 Answer

Changing the font of a textmesh? 1 Answer

3d text with z axis depth 1 Answer

How do I scale the results of GetCharacterInfo? 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