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 ArkarKyaw · Sep 07, 2012 at 01:50 AM · updateguitext

Update function dosent update for GuiText.text

I want to update GuiText.text line by line after reading text file? Unfortunately GuiText.text dosent update even it is in update() function. Is there any issue ? Please help me. My code is as below:

 string subtitle;
 void AddSubtitle(string text)
 {
   subtitle = text;
 }
 
 void Update () 
 {
         subtitle.guiText.text = subtitle;
         Debug.Log(subtitle.guiText.text);
 }

※the value in the debug.log() is changing every fps.

Comment
Add comment · Show 2
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 by0log1c · Sep 07, 2012 at 04:20 AM 0
Share

Its not clear to me if the text doesn't update or if it changes every frame, neither how AddSubtitle is called. I'm also wondering if you want to display each single line for X time or have them add up until the whole file is displayed?

avatar image ArkarKyaw · Sep 07, 2012 at 04:45 AM 0
Share

It has some restriction to show.For example,there are 3 lines in the file A,B,C I just want to show Line B.I have to check current line is line B or not and should to display on the screen or not.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Sep 07, 2012 at 05:47 AM

Is that something like this that you need?:

 var str:String[] = new String[3]; 
 str[0]="Line1";
 str[1]="Line2";
 str[2]="Line3";
 var index :int;
 var guiOn:boolean;
 
 function Start(){
 guiOn=true;
 index =0;
 guiText.text = str[index];
 }
 
 function Update () {
     if (Input.GetKeyDown (KeyCode.Space)&&guiOn)
         ChangeGUI();
 }
 
 function ChangeGUI(){
     index++;
     if(index>=3){
         guiText.enabled=false;
         guiOn=!guiOn;
         }else guiText.text = str[index];    
 }


Here is just a simple script that will print the corresponding string and you get to the next one with space. Once you read them all, the GUI is disabled.

Oh and this is directly attached to the GuiText object so you would have to get the component first for your case.

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 ArkarKyaw · Sep 07, 2012 at 06:22 AM 0
Share

fafase san,Thank you for your answer.But it is still dosent work.I think that is Unity bug.

avatar image fafase · Sep 07, 2012 at 06:57 AM 0
Share

What is not working? because it works fine for me.

avatar image ArkarKyaw · Sep 07, 2012 at 07:25 AM 0
Share

I known that problem.$$anonymous$$y GuiText is not gameobject.That is prefab. It is work when i use as a GameObject. It dosent work as prefab.After loaded from prefab as a gameobject and instantiate. Do you know any way?

avatar image
0

Answer by hirenkacha · Sep 07, 2012 at 06:54 AM

check for the Console Collapse tab. If its selected, same Log will be collapsed.

Comment
Add comment · Show 1 · 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 ArkarKyaw · Sep 07, 2012 at 07:01 AM 0
Share

Yes,I also checked Console.GuiText.text value are updated in console window but not on object in the screen.I was testing with many way.

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

10 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

Related Questions

Update Guitext every frame 1 Answer

GUIText doesn't update 2 Answers

GUIText not updating score.... 1 Answer

Timer lag at GUIText drawing. 1 Answer

Update call for Multiple GUIText fails 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