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. Dismiss Notice

Where's IAsyncEnumerable<T>?

Discussion in 'Scripting' started by Romaleks360, Feb 28, 2022.

  1. Romaleks360

    Romaleks360

    Joined:
    Sep 9, 2017
    Posts:
    69
    I am using Unity 2020.3 with enabled support for C# 8. I am able to use await foreach, switch expressions and other fancy stuff. UniTask's IUniTaskAsyncEnumerable also works fine. But I would like to use the default .NET implementation - IAsyncEnumerable<T>.
    However, I get the "type or namespace name 'IAsyncEnumerable<>' could not be found" error, even with the "using System.Collections.Generic;"
    I guess it's not included in Unity's version of the framework. Where can I get it?
    And how to know what else isn't included?
     
  2. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,114
  3. Romaleks360

    Romaleks360

    Joined:
    Sep 9, 2017
    Posts:
    69
    Your links really helped! IAsyncEnumerable is the part of async streams, and they are indeed in the list of unsupported features. It's still possible to use them with UniTask though, but the syntax is a bit different.
    https://github.com/Cysharp/UniTask#asyncenumerable-and-async-linq
     
  4. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,049
    Have you test this feature in unity 2022.2 yet ?
     
  5. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,271
    2022.2. and later supports `IAsyncEnumerable`