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
0
Question by paatz04 · Apr 17, 2018 at 11:33 AM · textcanvascoroutinewaitforsecondsanimated-text

Changing text on Canvas Text is very slow / unresponsive

Hi,

I'm trying to animate a text on a Canvas/Text with the following snippet:

 foreach (char letter in message.ToCharArray()) {
             txtCanvas.text += letter;
             yield return new WaitForSeconds (letterPause);
             //Debug.Log(Time.time);
 }

It works but it is incredibly slow... I cannot even get 5 characters drawn per second. Even when the game runs at 100 FPS in the editor, the characters on the string won't be animating smoothly.

Any hint or clue what I'm doing wrong ?

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 Harinezumi · Apr 18, 2018 at 03:20 PM 0
Share

Have you tried using Text$$anonymous$$eshPro (now free with Unity) ins$$anonymous$$d of Unity UI's Text component?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MechaWolf99 · Apr 17, 2018 at 01:55 PM

My guess would be yield return new WaitForSeconds (letterPause);. But I don't know what letterPause is set to. What is it set to?

Comment
Add comment · Show 4 · 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 paatz04 · Apr 18, 2018 at 12:53 PM 0
Share

Thanks $$anonymous$$echaWolf! $$anonymous$$y bad forgot to mention- but no. For any letterPause it won't work smoothly. With letter pause of 0.033 it should draw 33 characters per second but it does maybe 4-5.... with 0.1 it does maybe 2-3.

avatar image MechaWolf99 · Apr 18, 2018 at 02:05 PM 0
Share

Okay, so I did a quick google search for you and found this other question.

Then did a very small modification to it to make it work for text canvas. Hope this helps :)

     private Text text;
 
     // Use this for initialization
     void Start () {
         text = GetComponent<Text>();
         StartCoroutine(AnimateText(text.text));
     }
 
     IEnumerator AnimateText(string strComplete)
     {
         int i = 0;
         text.text = "";
         while (i < strComplete.Length)
         {
             text.text += strComplete[i++];
             yield return new WaitForSeconds(0.03F);
         }
     }

avatar image paatz04 · Apr 18, 2018 at 03:09 PM 0
Share

This is just a different way of writing the for loop... Unfortunately doesn't help

avatar image MechaWolf99 · Apr 18, 2018 at 07:38 PM 0
Share

Did you try that code? Like, only that code in it's own script, on the same gameObject as the text element? Because I tried it before posting and it worked perfectly.

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

84 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

yield WaitForSeconds compatibility? 0 Answers

WaitForSeconds does not work 1 Answer

How do i position this text to go where i want? 1 Answer

How To Show 2d Text After Collision (3D Game btw) 0 Answers

Coroutine sequence not running properly 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