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 Sabroan · Jul 29, 2016 at 06:59 PM · startcoroutine

StartCoroutine not working.

Hi, I am trying to add something like loading screen on start to show my logo and let game load files. But for some reason my coroutine doesn't start. Now I looked over this 20x times and I still don't see what is wrong with this code.

   void Start()
     {
 
      ....
         StartCoroutine(HideLoadingScreen());
 }

and

   IEnumerator HideLoadingScreen()
     {
         print("started counting");
         yield return new WaitForSeconds(3);
   
         LoadingScreen.SetActive(false);
         print("finished  counting");
     }

Why is this happening? What is wrong with this code

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

4 Replies

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

Answer by Bunny83 · Aug 01, 2016 at 01:53 PM

I don't see any reason why this shouldn't work, considering the information you provided. What exactly represents the "...." in Start? Could it be that you receive any errors in the console? Do you destroy the gameobject anywhere? Do you load a different scene somewhere? Maybe you have an early-exit statement somewhere before your StartCoroutine call? Any of those actions would prevent the coroutine from completing / executing.

  • Do you actually get any of your prints in the console? If not any errors?

  • Have you tried adding a pring / Debug.Log right before you call StartCoroutine?

  • If that doesn't print as well make sure your gameobject is active (the checkbox at the top left in the inspector)

  • Also make sure your script component is enabled (the checkbox at the top left of your script component.)

Keep in mind that other script could interfere with your script. Maybe another script somewhere changes the level or destroys your gameobject?

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 CaptainIsolation · Mar 10 at 07:35 PM 0
Share

See Skurlexx's answer below

StartCoroutine("HideLoadingScreen");

In OP's code, the output of the method HideLoadingScreen() would be passed into StartCoroutine, not the name of the method to start

avatar image
1

Answer by danivdwerf · Jul 29, 2016 at 07:49 PM

do you have

using System.Collections;
at the top of your code?

Also, is the script assigned to something??

goodluck man

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 Sabroan · Aug 01, 2016 at 10:41 AM 0
Share

Yes, and yes. Still no idea why it's not working. Everything is as it should be. Ps. Sorry for late response

avatar image
1

Answer by Skurlexx · Oct 07, 2017 at 09:07 PM

StartCoroutine("HideLoadingScreen");

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 CaptainIsolation · Mar 10 at 08:01 PM 0
Share

This was OP's issue

avatar image
0

Answer by CaptainIsolation · Mar 10 at 08:00 PM

Not likely for everyone, but my issue was because I had an overload of the method without a parameter.

 IEnumerator sameMethodName(string value){
 ...
 }
 
 void sameMethodName(){
 ...
 }

Renaming the method I didn't want fixed the problem

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

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

7 People are following this question.

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

Related Questions

Invoke a Coroutine From OnCollisionEnter 1 Answer

C# change light color every few seconds 3 Answers

understanding coroutines 0 Answers

StartCoroutine in a public static void 1 Answer

Yield position within while loop in coroutine 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