This article is more than 1 year old

Unity devs warned of breaking changes ahead in video game engine as team gets to grips with mutating face of .NET

Support has fallen behind and fixing it is a challenge

Unity software developer Josh Peterson has spoken about the future of .NET support in the widely used game development engine.

Use in game development is one of the bright spots for C# popularity, according to a survey late last year, but its use in Unity is somewhat messy.

The C# scripting engine is based on Mono but developers may also use .NET Framework when running on Windows. Mono is the old open-source implementation of .NET, from before Microsoft itself came out with .NET Core. Microsoft acquired the stewardship of Mono with Xamarin in 2016, and Mono now shares substantial code with .NET Core, but it remains distinct and the runtime is still used in some scenarios.

Unity maintains its own fork of Mono, which Peterson said is "about two years behind the latest upstream code." The team is now updating this to the latest code from the upstream Mono repository, a change he is "95 per cent confident" will make it into the next release, Unity 2021.2. He added that this exercise will improve performance and fix bugs but in itself "won't have any new .NET features" – though it lays the ground for features to be added in future.

That said, Peterson does expect to add support for .NET Standard 2.1 in Unity 2021.2, but this time with only "75 per cent confidence." The .NET Standard versions define the set of APIs that a .NET implementation must support. A tricky aspect of .NET Standard 2.1 is that .NET Framework is stuck forever on .NET Standard 2.0. Peterson said: "Although .NET Framework does not support .NET Standard 2.1, Mono's class libraries do support it, so we should be able to provide a nice bridge to a .NET Core-based ecosystem."

The upgrade cannot come soon enough for some developers frustrated with the slow progress. "Are there any strides towards ditching Mono in favour of a complete .NET integration? Especially now when .NET is becoming so cross-platform," asked a user in August last year. In-demand features include Span<T>, introduced in C# 7.2, and the Range operator, introduced in C# 8.0. Microsoft released C# 8.0 in September 2019, and getting the complete set of features into Unity has taken a long while. Users are also concerned that .NET performance in Unity has fallen behind.

Peterson said that C# 8.0 support will still be based on Mono in 2021.2. He also expressed hope that C# 9.0, released by Microsoft in November 2020, will be supported, but this depends on adding features to Mono and to IL2CPP (which converts .NET code to C++ for compilation), and for this his confidence descended to 50 per cent, he said.

As for that request to migrate to .NET Core, this is not likely soon. Peterson said that Unity will probably skip .NET 5 in favour of .NET 6, which is the forthcoming long-term support release. Even then, he said that "it looks like the JIT runtime here will be Mono" but he is uncertain and added that "we may need to move directly to CoreCLR for .NET 6 support."

One of the issues is that a feature of the Unity editor called domain reloading, which resets the scripting state, depends on a feature (AppDomains) that does not exist in .NET Core. Peterson said this could be implemented another way but "will be a breaking change." For game developers, .NET 6 will be a breaking change anyway since "any assemblies compiled against mscorlib.dll from the .NET Framework ecosystem will not work, and must be recompiled."

The complexity around .NET Standard, .NET Framework, .NET Core, and Mono is a challenge for Unity's developers, and shows that Microsoft's unification of .NET is in reality a process, not something that happened overnight with the release of .NET 5.0 last year.

"The only thing I'm interested in is the .NET 6 support. The biggest problem I had was slow Editor performance and long iteration time as project size grows. I currently ditched Unity because it was too painful to use and moved to Unreal right now," said another user, adding that "Mono will be history soon and it has no future."

In a separate post, Peterson emphasised that "everything discussed here is subject to change. Please do not consider discussions on this thread to be official announcements." Instead, he said that they offer "insight on our progress." ®

More about

More about

More about

TIP US OFF

Send us news


Other stories you might like