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 /
  • Help Room /
avatar image
0
Question by JACKO4590 · Sep 11, 2016 at 06:45 AM · scripting problemcoroutinewaitforsecondsyield waitforseconds

C# coroutine not waiting on waitForSeconds?

Ok this should work but I dont know if its stopping on yield return or just hasn't finished. Im not getting debug 3 and my level is not loading the next scene. am i doing something wrong? Using unity 5.4.0

 using UnityEngine;
 using System.Collections;
 using UnityEngine.SceneManagement;
 
 public class SplashScreen : MonoBehaviour {
 
     public float waitTimer;
     public int levelIndex;
     public KeyCode skipKey;
 
     void Start() {
         Debug.Log("1");
         StartCoroutine(SplashWait());
     }
 
     void Update() {
         if (Input.GetKey(skipKey)) {
             StopAllCoroutines();
             SceneManager.LoadScene(levelIndex);
         }
     }
 
     IEnumerator SplashWait() {
         Debug.Log("2");
         yield return new WaitForSeconds(waitTimer);
         Debug.Log("3");
         SceneManager.LoadScene(levelIndex);
     }
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by JACKO4590 · Sep 11, 2016 at 08:18 AM

Hahaha found it. Time scale was set to 0 for some f-ed up reason, i was about to rip my hair out.

Comment
Add comment · 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
0

Answer by doublemax · Sep 11, 2016 at 07:49 AM

I tested the script and it works as expected. Did you set a reasonable value for waitTimer ?

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 JACKO4590 · Sep 11, 2016 at 07:55 AM 0
Share

Yeah mate. I set it to 3 and even set it to 1 just for testing. Putting null in s$$anonymous$$d of wait works but not what I want. If it works on yours then there must be something on my end?

avatar image doublemax JACKO4590 · Sep 11, 2016 at 08:00 AM 0
Share

I don't see anything that could go wrong here. Try creating a new empty project, add one object and attach the script to it and see what happens.

What happens in of outcomment the LoadScrene call in SplashWait? Do you get the "3"?

avatar image JACKO4590 doublemax · Sep 11, 2016 at 08:19 AM 0
Share

Thank you for you help, it was time scale set to 0 that was stopping coroutine running

avatar image JACKO4590 · Sep 11, 2016 at 08:15 AM 0
Share

New project and it worked.

The only object i have in my main scene is the game jam menu. Other then that Realistic FPS prefab is the other asset i have imported that re writes system settings like tags, layers ect

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

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

Related Questions

StartCoroutine not listening to parameters 1 Answer

Could not load source 'Coroutines.cs': No source available. 1 Answer

Coroutine not working as expected 1 Answer

Coroutine problem with elevator 1 Answer

WaitForSeconds. Completely lost with this 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