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 moghes · Jun 16, 2012 at 10:16 AM · instantiatetextruntimeguitext

Change The GuiText.text by code

Hello EveryOne! I have a small issue here: I want to display the tag for my prefab as a title which is a GuiText. I have the script named "InstantiatePrefab", and the portion for this issue is here:

 var modelTitle:GUIText; //dragged reference
 function CreateNext()
 {    
     Destroy(prefab); 
     count++;
     prefab = Instantiate (myArray[count], gameObject.transform.position , Quaternion.identity);
     prefab.transform.parent = transform;
     modelTitle.text = prefab.tag;
 }

I want simply to display the user of what is the model he see's (ex: Eiffel Tower), I am sure I have set the tag for my models.

Comment
Add comment · Show 5
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 tomekkie2 · Jun 16, 2012 at 11:03 AM 0
Share

If you can see your GUItext object on the screen, and have attached that to the modelTitle variable in the inspector, tags are registered and attached to your prefabs, you get not any errors on the script execution, it would be difficult to see any reason for your titles to not display.

avatar image moghes · Jun 16, 2012 at 12:34 PM 0
Share

I had to do modelTitle.guiTexture.text = prefab.tag; ins$$anonymous$$d of modelTitle.text = prefab.tag;

avatar image Wolfram · Jun 16, 2012 at 01:08 PM 2
Share

That doesn't make any sense, as a GUITexture doesn't have a "text" property, but as long as it worked out for you...

avatar image tomekkie2 · Jun 16, 2012 at 01:16 PM 0
Share

Could you clarify, moghes, as far as I know, text is not the property of guiTexture.

avatar image moghes · Jun 23, 2012 at 03:58 AM 0
Share

yes its not a property of guitexture and that's why it didn't work the first time, u are right

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tim-Michels · Jun 19, 2012 at 10:40 AM

I would use a TextMesh. Simply add a 3D Text object to the scene, which has a TextMesh component. The text can by changed by setting TextMesh.text = "test";

If you're having problems with the sharpness of the text, change the import settings of the font. The size property in the import settings is default pretty low, so make this size higher, and downscale the Textmesh gameobject accordingly.

Cheers

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

6 People are following this question.

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

Related Questions

Instantiate and edit a text box during runtime 1 Answer

How would I make the text bigger on this script? 1 Answer

GUIText Instantiation and Update the Instantiated Text. C# 1 Answer

HELP! Make text appear in scene after 5 seconds? 2 Answers

How to display Greek alphabets 0 Answers


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