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 Filippopotamus · Jun 28, 2013 at 06:56 PM · coroutinecoroutines

Coroutine stopping before it is complete

I have a coroutine that starts other coroutines and waits for them to complete in order for them to animate sequentially. However, the coroutine stops half way through and I don't know why. (I am not calling StopCoroutinesAllCoroutines() anywhere). Any idea why?

 public IEnumerator ShowPreGameScreen(bool animated, bool waitForCompletion)
 {
         print ("Got Here 1"); // <-- prints
         yield return StartCoroutine(preGameScreen.Show(animated, waitForCompletion)); // <-- executes
         print ("Got Here 2"); // <-- does NOT print
         yield return StartCoroutine(ShowTopBar(animated, waitForCompletion)); // <-- does NOT execute
         print ("Got Here 3"); // <-- does NOT print    
 }
Comment
Add comment · Show 4
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 JChilton · Jun 28, 2013 at 07:00 PM 0
Share

Can you show us what's happening in preGameScreen.Show() ?

avatar image Filippopotamus · Jun 28, 2013 at 07:09 PM 0
Share

Here you go:

     public virtual IEnumerator Show(bool animated, bool waitForCompletion){
         PrepareForShow();
         
         if(animated){
             if(showAnimation == null){
                 print ("You are trying to Show a Screen with a null Show animation. Add a Show Animation to your Screen.");
                 panel.gameObject.SetActive(true);
                 yield break;
             }
             
             ActiveAnimation.Play(animations, showAnimation.name, AnimationOrTween.Direction.Forward, AnimationOrTween.EnableCondition.EnableThenPlay,
                                  AnimationOrTween.DisableCondition.DoNotDisable);
             
             if(waitForCompletion){
                 yield return StartCoroutine(WaitForAnimationComplete(showAnimation));
             }
         }
         else{
             panel.gameObject.SetActive(true);
         }
         
         yield break;
     }
avatar image JChilton · Jun 28, 2013 at 07:14 PM 0
Share

There is a chance that WaitForAnimationComplete() hasn't finished yet/ever ? Can you confirm that that coroutine is finishing?

avatar image Filippopotamus · Jul 11, 2013 at 11:47 PM 0
Share

Somehow the problem came back. here:

     IEnumerator WaitForAnimationComplete(AnimationClip clip){
         if(animations == null) yield break;
         if(clip       == null) yield break;
         
         print ("Waiting for animation completion: " + clip.length + " secs"); // Gets printed with 0.16667 as clip length
         
         yield return new WaitForSeconds(clip.length); // Never comes back from it!
         
         print("Done"); // Does NOT get printed!
     }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Filippopotamus · Jun 28, 2013 at 07:15 PM

Derp. Found the problem. My "WaitForAnimationComplete()" function was getting stuck. Now why animation.IsPlaying returns true forever I don't know. But that was my problem. Sorry for wasting your time.

Comment
Add comment · Show 2 · 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 JChilton · Jun 28, 2013 at 07:16 PM 0
Share

Haha I had just commented asking if it was or not :P

avatar image Filippopotamus · Jun 28, 2013 at 07:19 PM 0
Share

Funny how you can look over and over at your code and not find the problem. Then the second you post it online you figure it out. Thanks for the help :)

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

16 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

Related Questions

Nested Coroutines: last coroutine quits early 1 Answer

I need to Stop and Restart a Co-Routine at anytime 1 Answer

coroutine not running after yield new WaitForSeconds 1 Answer

How to properly implement a constant queue of actions in the background,How to properly implement a continuous background queue of actions? 1 Answer

Why doesn't a coroutine start executing from beginning when I start it again? 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