Search Unity

Coroutine in Lambda?

Discussion in 'Scripting' started by pretender, Apr 29, 2014.

  1. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    Hi!

    is it somehow possible to have coroutine execute in lambda?
    some syntax like this:

    Code (csharp):
    1.  
    2. {
    3.   () => yield return new WaitForSeconds(1f);
    4.   Debug.Log("Executed after pause");
    5. }
    6.  
     
    psyren likes this.
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
  3. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Even if it were supported it would probably puke on AOT compilers. That being said, if Unity ever gets .NET 4 support, assuming you're looking for some Async type functionality, maybe we'll be able to use the Parallels library (like Parallel.ForEach) which takes in a lambda / anonymous method and could likely accomplish what you're trying to accomplish...