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 /
This question was closed Apr 30, 2020 at 10:06 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by Ibe · Feb 10, 2015 at 12:15 PM · coroutineyieldyield waitforseconds

Coroutines Didn't Work After Changing Scene

Hi Everyone! I have this small problem and this problem starts to annoy me so I decided to ask a new question.

I have this scripts that simply gives the animation of typing text

     IEnumerator ThxForPlayTextAnim() {
         txtExit.text="";
         txtGoodBye = "Thank You For Playing";
         txtExit.gameObject.transform.localPosition = new Vector3(0,0,-0.61f);
         for (int i = 0; i<txtGoodBye.Length;i++ ) {
             if (i == 9)
                 txtExit.text += "\n";
             else
                 txtExit.text += txtGoodBye[i].ToString();
             yield return new WaitForSeconds(0.08f);
         }
         yield return new WaitForSeconds(0.5f);
         Application.Quit();
     }

I run this code and this works just as I wanted. But then After Changing Scene I noticed something strange.

The line where the yield return new WaitForSeconds(0.08f); did not work and thus the animation within the loop. It freezes. I've been searching around seeking answers but I still can't find any

Can anyone tell me what's wrong?

Comment
Comments Locked · 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 Bonfire-Boy · Feb 10, 2015 at 12:37 PM 0
Share

Is the object that the Coroutine is on being destroyed when you change scene? (you can check this using its OnDestroy() function). If it's destroyed, its coroutines will be ter$$anonymous$$ated.

avatar image Ibe · Feb 10, 2015 at 12:42 PM 0
Share

nope it is not destroyed, it is an entirely different coroutine in different scene. I have found the problem and solved it. But thank you so much for your response! I really appreciated it

1 Reply

  • Sort: 
avatar image
10
Best Answer

Answer by Ibe · Feb 10, 2015 at 12:54 PM

I have found the problem, just if someone have the same problem.

The code works fine but not with the other script. I purposedly change the time.timescle in the previous scene to pause the game and the game transferred to the other scene having the time.timescale to be 0, making all coroutine to be stopped in the yield statement.

Adding the time.timescale = 1 fixed everything in my case

Comment
Comments Locked · 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 JuanDavid0705 · Jul 15, 2016 at 02:06 AM 0
Share

Thanks Ibe, thanks :D

I put Time.timeScale = 1 in Update Function and the scene WOR$$anonymous$$S!

avatar image moh05 · Nov 23, 2016 at 12:22 PM 0
Share

Hello,

I have the exact problem but my timescale is still 1

Any other solution?

avatar image Bunny83 moh05 · Nov 23, 2016 at 12:25 PM 0
Share

Are you sure that Bonfire-Bon's comment above doesn't apply to you? If not you should ask a seperate question since your problem clearly is not the same.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Coroutoutine doesnt work properly. 3 Answers

WaitForSeconds is breaking out of my IEnumerator 1 Answer

Is there a yield WaitForSeconds type code for the update? 2 Answers

Is there any way to stop WaitForSeconds() ? 1 Answer

Invoke repeating OR coroutine with WaitForSeconds? 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