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
0
Question by TargonStudios · Apr 09, 2013 at 12:21 AM · 3dtext

Changing 3D text through script

So basically, I want a script that shows the number of "players_knights" in a 3D text, but I've searched everywhere and have tried everything but haven't been able to get anything to work. so can someone help me make this script be able to show on to a 3D text? (oh and the most common problem I've had is "Cannot convert "int" to "String" " something like that.)

SCRIPT:

 var players_knights = 20;
 
 function Update() {
 
 }
 

  
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

1 Reply

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

Answer by iwaldrop · Apr 09, 2013 at 01:52 AM

I seriously doubt that you've searched 'everywhere' and tried 'everything'. I tried this, and it worked.

 using UnityEngine;
 using System.Collections;
 
 public class Text : MonoBehaviour
 {
     private TextMesh text;
     
     void Awake()
     {
         text = gameObject.AddComponent<TextMesh>();
         
         text.text = Time.time.ToString();
     }
     
     void Update()
     {
         text.text = Time.time.ToString();
     }
 }
 
Comment
Add comment · Show 5 · 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 TargonStudios · Apr 09, 2013 at 11:31 AM 0
Share

thanks a bunch :D, but would it be ok if it was java script? I just have never used C#.

avatar image iwaldrop · Apr 09, 2013 at 03:58 PM 1
Share

Sure, you can do the same stuff in JavaScript. This isn't a site to come and have other people do your coding though, the above was just an example. It's really easy to convert this in to js, so give it a shot! If you have problems, then come back and ask a specific question. :)

avatar image Kinou · Aug 06, 2014 at 02:33 PM 0
Share

Unfortunately, even this is not doing a thing for me :(

See, I have a 3D text in my main scene. I have attached a script to it :

public class updateName : $$anonymous$$onoBehaviour {

 private GameController$$anonymous$$aster master_;

 private Text$$anonymous$$esh titleText$$anonymous$$esh_;

 /*
  * Start()
  * 
  * We find the menu's controller.
  */
 void Start () 
 {
     master_ = (GameController$$anonymous$$aster)GameObject.FindGameObjectWithTag (Tags.menuController).GetComponent (typeof(GameController$$anonymous$$aster));

     //titleText$$anonymous$$esh_ = (Text$$anonymous$$esh) gameObject.GetComponent (typeof(Text$$anonymous$$esh));

     titleText$$anonymous$$esh_ = gameObject.AddComponent<Text$$anonymous$$esh> ();

     if(master_.isNameSet())
     {
         titleText$$anonymous$$esh_.text = "no change";
     }
 }
 
 /*
  * Update()
  * 
  * We check the name again and again.
  */
 void Update () 
 {
     if(master_.isNameSet())
     {
         titleText$$anonymous$$esh_.text = "no change";
     }
     else
     {
         titleText$$anonymous$$esh_.text = "Hello " + master_.getName() + "!";
     }
 }

}

As you can see, I have tried to GET the 3D text's Text$$anonymous$$esh, without any succees. The text, which I have orginially set in the game view, never changes. BUT I get no error or warning. What may be the problem?

Ah, also : I retrieve the text from a game controller located in another scene used as the menu. Could that be the problem?

avatar image meat5000 ♦ · Aug 06, 2014 at 02:37 PM 0
Share

Is that maybe because you commented out the GetComponent line and so are no longer linking to the actual object?

avatar image Golden_Obsidian · Dec 04, 2016 at 08:06 AM 0
Share

Sir, I had no idea what was wrong with my code, and then realized I forgot the () after ToString. It's 3 am, I don't know why I felt the need to make an account and thank you.

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

12 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

Related Questions

Changing the colour of a 3DText through script gives a weird error 0 Answers

Can't Assign 3DText to the script 1 Answer

Can't change the 'text' of a 3DText object through a script, no matter what I do. 1 Answer

Help with Gui texture/Audio 1 Answer

GUI Script Help 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