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
1
Question by Grady · Jul 03, 2011 at 10:24 AM · textmeshdraw3dtext

How to draw 3D text from code

Hey guys,

I was wondering, how can you draw 3D text from code???

Thanks

-Grady

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 SisterKy · Jul 15, 2011 at 01:32 AM 0
Share

Retagged 3d, text to 3dtext and textmesh. Greetz, $$anonymous$$y.

4 Replies

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

Answer by LegionIsTaken · Jul 05, 2011 at 09:04 AM

You can also do this:

 var TEXT : Textmesh; // Drag your 3d text here in the inspector.
 
 function Update ()
 {
 TEXT.text = "I just answered your question! I hope this helps";
 }

Done. :)

Comment
Add comment · Show 8 · 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 Marnix · Jul 05, 2011 at 09:15 AM 0
Share

This is not "from code" =)

avatar image Grady · Jul 05, 2011 at 10:03 AM 0
Share

just to clear this up from both examples, what i am meant to do is create an empty game object in the hierarchy, and then attach Component -> $$anonymous$$esh -> Text $$anonymous$$esh to it. Then drag that into the variable????? because in Legion's example, that's what i did, but nothing came up, for Legion's example, am I actually supposed to create a 3D text game object in the hierarchy????

avatar image Grady · Jul 05, 2011 at 10:06 AM 0
Share

ok, with Legion's example, i managed to get the script to work with a 3d text object, but i need the text to appear and then dissapear within another script, so say when the user presses a button, then it should appear, and then when they press it again, then it dissapears....

and also, is it possible to make the text appear at any place within the scene from the script?

avatar image Marnix · Jul 05, 2011 at 10:17 AM 0
Share

Yes, you can enable and disable the $$anonymous$$eshRenderer that is also attached to the GameObject. textGameObject.GetComponent("$$anonymous$$eshRenderer").enabled = false.

avatar image Grady · Jul 05, 2011 at 10:37 AM 0
Share

O$$anonymous$$, I'm using Legion's example, but what do I do? considering you both helped just as much.... I don't know who to give the right answer to... unless you guys want me to vote up both your answers or something.... :P

Show more comments
avatar image
4

Answer by Marnix · Jul 03, 2011 at 10:27 AM

Use a `TextMesh`. There is also a script reference, which should definitely help you to create the text you are looking for.

Update
To create this in code, you can just add a component to your empty GameObject.

 //somewhere in some manager object
 function Awake()
 {
     var theText = new GameObject();
     
     var textMesh = theText.AddComponent("TextMesh");
     var meshRenderer = theText.AddComponent("MeshRenderer");
 
     // do some settings here that are needed in the component
     // set the text
     textMesh.text = "Hello World!";
 }

It depends if you need to set a font or not, because I don't know if there is a default one. Please check that in your Hierarchy.

Comment
Add comment · Show 12 · 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 Grady · Jul 03, 2011 at 10:36 AM 0
Share

So do I make the 3d text in the heirarchy first?

avatar image Marnix · Jul 03, 2011 at 10:48 AM 0
Share

@Grady Updated my answer. Hope this will help you further.

avatar image Grady · Jul 03, 2011 at 11:39 PM 0
Share

what do i put in "the text" variable? is that supposed to be a premade 3d text or something????

avatar image Marnix · Jul 04, 2011 at 09:09 AM 0
Share

I think you also need to add a meshrenderer. As you can see in the Text$$anonymous$$esh link I provided. Will update my answer.

avatar image Grady · Jul 04, 2011 at 11:04 PM 0
Share

i keep getting the following error in the console: "ArgumentException: You are not allowed to call Internal_CreateGameObject when declaring a variable. $$anonymous$$ove it to the line after without a variable declaration."

I'm not sure what I've done wrong...

-Grady

Show more comments
avatar image
0

Answer by 1099 · Oct 06, 2012 at 02:02 PM

Where Do You Go

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 murl1845 · Dec 02, 2020 at 12:34 AM

You can generate 3D text from code in many ways .One of this is, you first create a prefab of the characters , give it as an input to the script and then generate 3D text from script by instantiating gameobjects.

I found this YouTube video helpful https://youtu.be/B7mi3pXl0GM

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

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

8 People are following this question.

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

Related Questions

3D Text bug (text disappearing) 3 Answers

TextMesh update causing framerate drop 1 Answer

How to save 3d text 1 Answer

Updating LCD display? 1 Answer

How do you create genuine shadows from a Text Mesh? 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