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

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?

do you have

using System.Collections;

at the top of your code?

Also, is the script assigned to something??

goodluck man

StartCoroutine(“HideLoadingScreen”);

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