Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do you make a delay before repeating a function in vscode?

static void Main( ) {

Delay;

Function( );

}

static void Function( ) {

Console.WriteLine("Function Called");

}

Answers

  • Oops, I meant before calling.

  • HNJHNJ Member

    Is it C#, if yes, you will have to use Coroutines

    static void Main() {    
        StartCoroutine(Function());
    }
    
    IEnumerator Function()  {
        yield return new WaitForSeconds(5f); //5f is the seconds to wait
        Console.WriteLine("Function Called");
    }
    
  • I tried that. it works in visual studio when opened with unity, but doesn't work with visual studio code

Sign In or Register to comment.