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.

Coroutine missing hint and error

Discussion in 'Scripting' started by Patrick222, May 2, 2021.

  1. Patrick222

    Patrick222

    Joined:
    Apr 10, 2021
    Posts:
    1
    If i have a Coroutine IEnumerator ababa() there is no error or hint that something is wrong if i try to call the function ababa() without StartCoroutine(ababa())
    I had to look for hours to find this mistake because i forgot to write StartCoroutine in front of it, maybe it would be nice to implement a message in c# for that.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,554
    Kurt-Dekker likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    33,534
    This is so unnecessary. Use the beauty and power of instantly and immediately putting a Debug.Log() statement into the very start of the coroutine, right at the top.

    Do this always at the very first sign of trouble or question in your mind.

    The instant you did this you would see "Oh man, this code is simply not getting run!"

    And you could LASER-FOCUS 100% your efforts on studying what you expect to run it, eg., the call location, and isolate why it is not running.

    You would look at literally NOTHING else but that issue until your resolve that one issue.

    With that focus, you could also refer to any other successful coroutine anywhere else on the planet and go "Oh, I'm missing the StartCoroutine() wrapper!"
     
  4. ricardobilinski

    ricardobilinski

    Joined:
    Aug 3, 2021
    Posts:
    2
    This is very helpful thank you! I didnt even think to use Debug.Log(). I am going to try this out now.
     
    Kurt-Dekker likes this.