Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

yield WaitForSeconds (3); ON .CS

Discussion in 'Scripting' started by mauricito4, Aug 31, 2017.

  1. mauricito4

    mauricito4

    Joined:
    May 12, 2013
    Posts:
    120
    hi
    just toknow
    i use on java script
    yield WaitForSeconds (0.7);

    but i am trying touse on .cs
    how can i Do please ?

    thanks a lot !
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,450
    TaleOf4Gamers likes this.
  3. mauricito4

    mauricito4

    Joined:
    May 12, 2013
    Posts:
    120
    thanks a lot ... but they use

    IEnumerator Example()
    {

    how can i use only with void ?
    for example:

    void Example()
    {

    in other words ...
    how can I use without IEnumerator
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You can't use it without an IEnumerator in C#.

    In UnityScript the compiler put the IEnumerator in for you in the background. In C# you have to write it yourself.

    You also want to use StartCoroutine to launch your coroutine, instead of just calling the method directly.
     
  5. mauricito4

    mauricito4

    Joined:
    May 12, 2013
    Posts:
    120
    thanks so much ... is working now