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. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

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,266
    Kurt-Dekker likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    29,905
    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.