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 maaarcooose · Sep 04, 2014 at 06:25 AM · guitext

How to create GUI text box and update from script.

I'm having some trouble working this out.

I'm creating a 3d mapping program and want to have an info box on the right that is updated depending on what I click on but I must be missing something in how I access the text content of the GUI control.

Can someone point me in the right direction.

So I have the following TextField entry:

 GUI.TextField(new Rect(Screen.width-200,0,200,Screen.height-40),"Info");
 

How can I then either assign and object to access it publicly or name it to access the text field and update?

I'd really like to understand how to access this as I use GameObject.FindWithTag for other objects, so can I add a tag to a GUI element and access it that way?

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
0

Answer by dorpeleg · Sep 04, 2014 at 09:27 AM

If it's an info box, I'm guessing you don't want the user to be able to edit it right?

Use GUI.Label to display text the user can't edit.

In order to change the string during runtime, you will have to make a var.

Something like this:

 public string InfoText;
 void OnGUI()
 {
     GUI.Label(new Rect(Screen.width-200,0,200,Screen.height-40), InfoText);
 }

Then, you can change the InfoText from anywhere you want and it will update automatically.

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 maaarcooose · Sep 04, 2014 at 11:49 AM 0
Share

Okay, I have done this and then attempt to access from a differnet script which just tells me that it does not exist in the currrent context.

avatar image maaarcooose · Sep 04, 2014 at 12:42 PM 0
Share

I've changed to using a GUIText opject now as this seems to be less complicated to impliment what I want.

avatar image dorpeleg · Sep 09, 2014 at 07:36 AM 0
Share

@maaarcooose you probably doing something else wrong...

But If you went to a different solution that works for you, please close the question

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Using AutoType script on GUI.Label? 1 Answer

How to Load Text From External Text Document for GuiText by java Script... 1 Answer

Unity3d GUI Element Scaling 1 Answer

Placing a chat bubble above a character's head in a 3d environment 2 Answers

How to make a cutscene like RPG Games 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