logoalt Hacker News

pjc50today at 10:53 AM6 repliesview on HN

Always jarring to see how Unity is stuck on an ancient version of C#. The use of IEnumerable as a "generator" mechanic is quite a good hack though.


Replies

tyleotoday at 11:17 AM

Unity is currently on C# 9 and that IEnumerable trick is no longer needed in new codebases. async is properly supported.

Deukhoofdtoday at 12:15 PM

Thankfully they are actively working towards upgrading, Unity 6.8 (they're currently on 6.4) is supposed to move fully towards CoreCLR, and removing Mono. We'll then finally be able to move to C# 14 (from C# 9, which came out in 2020), as well as use newer .NET functionality.

https://discussions.unity.com/t/coreclr-scripting-and-ecs-st...

show 2 replies
Philip-J-Frytoday at 11:57 AM

>The use of IEnumerable as a "generator" mechanic is quite a good hack though.

Is that a hack? Is that not just exactly what IEnumerable and IEnumerator were built to do?

show 1 reply
debugniktoday at 11:06 AM

Not that ancient, they just haven't bothered to update their coroutine mechanism to async/await. The Stride engine does it with their own scheduler, for example.

Edit: Nevermind, they eventually bothered.

show 2 replies
ahokatoday at 11:57 AM

IIRC generators and co-routines are equivalent in a sense that you can implement one with the other.

show 1 reply
repelsteeltjetoday at 10:58 AM

Not too different from C++'s iterator interface for generators, I guess.